Forum Moderators: phranque
product.php?product=213
using
RewriteEngine on
RewriteRule ^product/(.*)\.html /product\.php\?product=$1
becomes
product/213.html
Now I'd like to use rewritecond so that if product.php?product=213 is requested, it redirects to product/213.html, but only if the request for product.php isn't a rewrite in the first place... I am sure this is possible. I hope I've explained this satisfactorily
The reason is to stop search engines listing the page twice...
thanks for any replies...
RewriteCond %{IS_SUBREQ}!^true$
RewriteCond %{QUERY_STRING} ^product=(\d*)(.*)
RewriteRule ^product\.php.* /product/%2\.html\? [R]
I thought I could do something like this, but it doesn't work because IS_SUBREQ doesn't do what I hoped it might. I tried using HTTP_FORWARDED too without results. If anybody has any hint as to what to do I'd love to hear from you... There must be some way to stop it from infinate looping... anybody?
if (! substr_count( $_SERVER['REQUEST_URI'],"/product/" ) ) {
header("Location: /product/$product_id.html");
exit();
}
It seems like you can't use the mod rewrite equivalent...
RewriteCond %{REQUEST_URI}!.*/product/.*
Anyobdy know why?