Gcole you're welcome actually I've tried many .htaccess and dunno how to get the url converted to ma taste and how to redirect the dynamic to the static one.

Download Now
  • Date: Jan 04, 2013

You said you knew how about htaccess rewrite rules.

So to convert the topic name to friendly text, run a str_replace on every invalid character.

e.g

Code
$text = str_replace(" ", "-", $text);

What that implies is replace all space ( ) with hyphen ( - ) in the string contained in the variable $te xt.

Also str_replace("@", "", $text);

Would replace all occurrence of (@) with nothing (no space in between the double-qoutes) and that implies that all @ in the string contained in the variable $text is deleted.

  • Date: Jan 04, 2013

Actually if you look at many sites you would see the id appears somewhere in the URL.

Like in mine you see forum/(id here)/ anytext.

So if you clean all the text in and type any character and went it with .html its still same content you get using my site as example.

for example. This thread has the URL
http://www.netnaija.com/forum/2063/-htaccess-converting-dynamic-url-to-static-url.html
If you clean everything and leave it as /forum/2063/sylva02.html you will get the same output.

I know I'm not supposed to post this but we learn everyday.

  • Date: Jan 04, 2013

I get that... @endycole this' famous..... And what I mean is how do I get that title forced into the url when requested... What changes to should be made to showtopic.php that when particular topic's been requested i.e example.tld/showtopic.php?id=AnyValue you have in your address bar example.tld/showtopic.php?id=AnyValue&title=htaccess-on-ma-mind ? Is it possible? Or lemme say ma major aim is getting a static url something like urs xample.tld/forum/25/how-to-get-title-into-url.html ?

  • Date: Jan 04, 2013

That is where you need a htaccess guide. Do a Google search.

I'm gonna give you a quick run.

You would edit your htaccess and add a rule to treat all forum/[number string]/[alphanumeric string].html as forum/showtopic.php?id=[number string]

Then you must edit everypage that has the url showtopic.php?id=id to forum/id/[replaced invalid characters on topic title].html

  • Date: Jan 04, 2013

You said you knew how about htaccess rewrite rules.

So to convert the topic name to friendly text, run a str_replace on every invalid character.

e.g

Code
$text = str_replace(" ", "-", $text);

What that implies is replace all space ( ) with hyphen ( - ) in the string contained in the variable $te xt.

Also str_replace("@", "", $text);

Would replace all occurrence of (@) with nothing (no space in between the double-qoutes) and that implies that all @ in the string contained in the variable $text is deleted.

Gerardcole

I'm not a best yet... Should this be sumthin like

Function str_replace($text)
blablabla...
in func.php? And how do I make it work in forum?

  • Date: Jan 04, 2013

I'm not a best yet... Should this be sumthin like

Function str_replace($text)
blablabla...
in func.php? And how do I make it work in forum?

Sylvar02

You can make it a function like

function invalidchars($string)
{
$string = str_replace(" ", "-", $string);
$string= str_replace("@", "", $string);

return $string;
}

You can then continues the trend using my examples. Then where you want to use it just put
$topicurl = invalidchars($topictitle);

  • Date: Jan 05, 2013

You can make it a function like

function invalidchars($string)
{
$string = str_replace(" ", "-", $string);
$string= str_replace("@", "", $string);

return $string;
}

You can then continues the trend using my examples. Then where you want to use it just put
$topicurl = invalidchars($topictitle);

Gerardcole


thanks boss it works!!! But the problem now is on ma host your .htaccess must have
RewriteBase/ directory/

which makes the directory the index folder... Now every link in ma showtopic after the rewrite rule ish has http://example.tld/forum/id/the link

i.e http://example.tld/forum/23/profile.php?id=3056

or the related topic ish
http//domain.tld/forum/23/23/245/title.html

where 245 is the related topic's id... Pls what to do to make this work perfectly... I applied same rule to ma topics.php and it worked perfectly

  • Date: Jan 05, 2013

You can make it a function like

function invalidchars($string)
{
$string = str_replace(" ", "-", $string);
$string= str_replace("@", "", $string);

return $string;
}

You can then continues the trend using my examples. Then where you want to use it just put
$topicurl = invalidchars($topictitle);

Gerardcole


thanks boss it works!!! But the problem now is on ma host your .htaccess must have
RewriteBaes/ directory/

which makes the directory the index folder... Now every link in ma showtopic after the rewrite rule ish has http://example.tld/forum/id/the link

i.e http://example.tld/forum/23/profile.php?id=3056

or the related topic ish
http//domain.tld/forum/23/23/245/title.html

where 245 is the related topic's id... Pls what to do to make this work perfectly... I applied same rule to ma topics.php and it worked perfectly

‹‹123››
Viewing Page 1 of 3 pages