Forum Moderators: phranque
The code which converts the URL to a new URL works great but the code to actually send the URL to the write place isn't working quite right.
This is what I have:
rewritecond %{REQUEST_URI} !^/products/
RewriteRule (.*)\.htm$ /proddetail.php?prod=$1
rewritecond %{REQUEST_URI} ^/products/
RewriteRule (.*)\.htm$ /products.php?cat=$1
The first part is supposed to send any requests that end in .htm and are not in the products directory to proddetail.php which works fine.
The second part is using rewritecond to limit it to products directory and then what ever ends in .htm sends to products.php?cat= and then the # before .htm.
This one does send it to products.php but it is not processing the id of the category. It basically gets "/products.php?cat=" every time.
I figure it's probably something fairly obvious but I can't figure it out.
Thanks for any help you can provide :)
That is, a request for the URL "example.com/products/123.htm" should be rewritten to the server filepath "/products.php?cat=products/123" as it stands right now.
I doubt it will fix your problem (which isn't obvious, given that no example URLs were provided), but a more-correct way to code the second rule would be
RewriteRule ^products/([^.]+)\.htm$ /products.php?cat=$1
Note that in a .htaccess context, the URL-path 'seen' by RewriteRule is stripped of the path to the current .htaccess directory, which in this case is "/". So the leading slash won't appear in the URL-path seen by the RewriteRule, and is therefore not present in the pattern I used here.
Jim