Forum Moderators: phranque
[website.com...]
instead of:
[website.com...]
The PHP page will still pass the two variables (id and name). I just want to eliminate the id in the html.
Any help would be greatly appreciated. I had someone setup my initial mod rewrite and have no clue what any of this means! Thanks for your help!
********************************************
Example 1:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^([0-9]+)-[^/]+\.html$ /manufacturer.php?brand_id=$1 [QSA,L]
From:
[website.com...]
To:
[website.com...]
********************************************
mod_rewrite does not change dynamic URLs to static URLs. Only you can do that by modifying your pages -- or rather, by modifying the script that produces your pages.
You (or someone) changed the dynamic "index.php?page=xyz"-type links on your pages to static "xyz.html" links on your pages. When someone clicks on that link, their browser makes a request to your server for "xyz.html".
But since your site is dynamic, the "page" "xyz.html" does not actually exist; There is no file on your server that represents the contents of that page. So at this point mod_rewrite is used to convert that "xyz.html" request into a call to your script with the parameters needed to build what the user and browser think is the "xyz.html" page.
So you cannot take the "3" out of the static URL, unless you want every page on your site to be built (by your php script) assuming that that parameter is always "3" or that it is never "3"; Those are the only two choices, unless you use a database to associate certain combinations of "manufacturer" and "treehouse" and derive that that value should be a "3".
In other words, you cannot create the information "3" out of thin air, and since the mod_rewrite operation goes in the opposite direction than what you expected, this is what would be required to do what you ask.
See this thread [webmasterworld.com] in the Apache forum section of the WebmasterWorld library [webmasterworld.com] and the documents cited in our forum charter [webmasterworld.com] for some background on how this all works.
Jim