Forum Moderators: phranque

Message Too Old, No Replies

.htaccess re-write

301 Re-Directs With .htaccess

         

creativexperience

10:50 am on Jul 1, 2007 (gmt 0)

10+ Year Member



Could someone give me a helping hand please.

Im sadly not an expert when it comes to dynamic url re-writing.

Im trying to do the following:

RewriteEngine On
RewriteBase /
RewriteRule details.php?i=19 DOMAIN/NAME.php [R=301,L]
RewriteRule products.php?c=6 DOMAIN/NAME.php [R=301,L]

But its not working, ive read around and come to the conclusion that some form of condition must be written, not sure how to :(

I have ID numbers ranging up to 36.

All help is appreciated

jdMorgan

6:52 pm on Jul 2, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's not clear exactly what you want to do, but query string must be handled separately:

RewriteEngine on
RewriteBase /
#
RewriteCond %{QUERY_STRING} ^i=19$
RewriteRule ^details\.php$ http://example.com/name.php [R=301,L]
#
RewriteCond %{QUERY_STRING} ^c=6$
RewriteRule ^products\.php$ http://example.com/name.php [R=301,L]

This code retains the existing query string and appends it to the "name.php" path. If you wish to clear the query string, then add a "?" to the substitution URL in the rule.

Jim