Forum Moderators: phranque
I just can not get my head around mod rewrite I either get 200 where i have not matched properly or server error. I have read books on general expressions and on mod rewrite and all the recommended reading but still I can not get them to work with out help. Please can someone advise on this. Thanks
301 redirect
www.mydomain.co.uk/product_info.php?manufacturers_ id=10&products_id=98&language=en
to
http://www.example.com/product_info.php/products_id/112
the reason is that google has index all my dynamic urls
thanks in advance
[edited by: jdMorgan at 2:22 pm (utc) on Nov. 14, 2005]
[edit reason] Example.com [/edit]
There are some comments on it here [webmasterworld.com].
And you will find quite a bit more information with a search like this in your favorite SE:
THE_REQUEST php site:webmasterworld.com/forum92/
When you have something you are working with, let us know and we will help you through the details.
Justin
I tried this
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /product_info\.php\?manufacturers_ id=([^&]+)&product_id=([^&]+)$
RewriteRule ^/?$ http://www.example.com [R=301,L]
but it goes into a loop and causes a 500 internal server error
thanks
[edited by: jdMorgan at 2:21 pm (utc) on Nov. 14, 2005]
[edit reason] Example.com [/edit]
301 redirect www.example.com/product_info.php?manufacturers_ id=10&products_id=98&language=en
to
http://www.example.com/product_info.php/products_id/112
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /product_info\.php\?manufacturers_ id=10&product_id=98
RewriteRule ^product_info\.php$ http://www.example.com/product_info.php/products_id/112? [R=301,L]
Also, check the path to your file and make sure it is correct in both the rule and condition...
You might also try it with the regular expressions:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /product_info\.php\?manufacturers_id=([^&]+)&product_id=([^\ ]+)
RewriteRule ^product_info\.php$ http://www.example.com/product_info.php/products_id/%2? [R=301,L]
I am not seeing anything glaringly wrong with the ruleset, so I would guess it is a minor path/browser error.
Justin
HEAD /product_info.php?manufacturers_id=1&products_id=9 HTTP/1.1
and the reply is
HTTP/1.1 200 OK
Date: Tue, 15 Nov 2005 13:22:19 GMT
Server: Apache/2.0.51 (Fedora)
X-Powered-By: PHP/4.3.10
Set-Cookie: osCsid=22404516c595c81dbd7b222192f8bcd6; path=/; domain=example.com
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache
Connection: close
Content-Type: text/html; charset=UTF-8
that is using justin's with the general expression
[edited by: jdMorgan at 2:09 pm (utc) on Nov. 15, 2005]
[edit reason] Example.com [/edit]
Also, you could change the sub-pattern "[^&]+" to "[0-9]+" just to see if your server has some strange regex library on it that's causing it not to work with "[^&]+". This pattern simply means "one or more characters not equal to an ampersand," and should work, but if it's not matching then try something else.
Jim