Forum Moderators: coopster
The apache way with .htaccess and the PHP way with the stargeek function.
I'm having a hard time with getting either method to work.
here is the URL I'm trying to rewrite:
domain.com/cat_display.php?catagory=BOOKS&subcat=SCARY&page=1
I'd like that to look like:
domain.com/cat_display.php/BOOKS/SCARY/1
so basically just convert the? to /
Can someone write the neccesary commands that would go into an .htaccess file for me? Or explain the syntax to me, or give me a link that explains the syntax.
Now to do this with the Stargeek PHP function, I mostly get but I don't understand how to use it exactly. If someone could explain that to me with detail or provide me a link that explains in details, I'd be most appreciative!
Thanks!
There are sme good tutorials out there, but the basic code I used is listed below.
In the past my pages were www.example.com/article/view.php?id=999
But I wanted www.example.com/article/999
I retained view.php but modified it, so that users could come from old links and the new format also.
Additionally, I have a line in .htaccess to invoke view.php on a 404 NOT FOUND (because 999 is neither a file nor a subfolder within article)
.htaccess:
ErrorDocument 404 /article/view.phpPHP:
$uri = $_SERVER['REQUEST_URI'];
$uri_array = explode("/",$uri);
$article_id = (integer) $uri_array[2];
In my case, $article_id now contains 999 and I can do with it what I did before.
I have further pages that accept more than one "variable", and have made them work as a variation on the above.
it's made for exectly that: url rewriting...