Forum Moderators: phranque
RewriteEngine on
Options +FollowSymlinks
rewriteBase /
RewriteCond %{REQUEST_URI} ^/catagory1.*
RewriteRule ^catagory1/(.*)\.html$
Search.bok?category=Catagory1:$1 [L]
which yeilds:
www.widgets.com/catagory1/product1.html
www.widgets.com/catagory1/product2.html
etc.
any idea how to get this code to drop those product files into root?:
www.widgets.com/example1.html
www.widgets.com/example2.html
thanks, doortodoororganics
The catch: If you do that, there will be no way for mod_rewrite to detect these "search-engine-friendly" requests and rewrite them back into the query form needed by your script. The "/category" string was used to "tag" these URLs as needing to be rewritten to the script, so changing it may require re-architecting your site.
You may find it better to simply shorten that name to "/cat1" rather than eliminating it.
It is important to understand how and *when* mod_rewrite works. Your pages contain links in the form "/category/product". The URLs in these links are seen by browsers and search engine bots. They may then request one of those URLs. When your server receives the request, the mod_rewrite code detects the "/category" part of the URL and recognizes that the URL needs to be rewritten to your script. So it changes the URL to point to your script, moves the "product" information into the query string, and then activates the content-handler to serve the requested content, which runs your script to produce the requested "page."
As such, mod_rewrite can change URLs in requests received by your server. It cannot change URLs output in pages (by scripts) on your server.
Jim