Forum Moderators: phranque
Just read up on the subject, but am still unclear on how to do this.
I have this URL...
www.example.com/category.php?currentSection=1
And I want to rewrite it to this...
www.example.com/browse/catone
As well as other URLs...
www.example.com/category.php?currentSection=2
www.example.com/browse/cattwo
www.example.com/category.php?currentSection=3
www.example.com/browse/catthree
How do I do this?
[edited by: jdMorgan at 4:14 pm (utc) on Sep. 9, 2008]
[edit reason] Use example.com please. [/edit]
Then you can use mod_rewrite to "re-connect" incoming client requests for those static URLs to your script, by translating them back into your original dynamic script filepath+query string format.
As an optional third step, you can redirect (only) direct client requests for the "old" dynamic URLs to the "new" static URLs, to speed up search engine re-indexing and to recover/preserve the pre-existing PageRank of those old URLs.
See this thread [webmasterworld.com] in our forum library for details, explanations, and instructions.
Jim
I understand this.
"Then you can use mod_rewrite to "re-connect" incoming client requests for those static URLs to your script, by translating them back into your original dynamic script filepath+query string format."
I understand this as well.
"As an optional third step, you can redirect (only) direct client requests for the "old" dynamic URLs to the "new" static URLs, to speed up search engine re-indexing and to recover/preserve the pre-existing PageRank of those old URLs."
That's something I read about too.
"See this thread in our forum library for details, explanations, and instructions. "
Looked over it and it's exactly what I've been reading, I still can't find something that specifically addresses my issue, thus the reason I posted my question here.
"Also, it will vastly simplify your code if you use "cat1," "cat2," "cat3," instead of "catone," "cattwo," "catthree." "
Good point. I used these for examples only. The actual names are things like "beauty", "health" and the like, not "catone" and "cattwo".
I just need the code that will tell the server to translate the numbers in the current urls (when typed into the address bar, not every url in the page) to words and then rewrite the url to http://www.example.com/browse/nameofcategory
I get the logic behind it, I just can't translate my logic into something the .htaccess file will read.
Alternately, if you have server-config file access (httpd.conf, conf.d, etc., you can define a RewriteMap. The RewriteMap can either use a lookup table, or it can call a small script (i.e. PERL) to open your database, read in the entry for the id number, retrieve the "word", and pass that back to mod_rewrite. This latter approach, while more complex, results in easier management, since all updates or additions can be done using your usual database-management tools -- The data is centralized in one place.
Jim