merimax
asked on
Help with RewriteRule
I need the proper Apache RewriteRule to do the following:
Current URL:
http://www.domain.com/mm5/merchant.mvc?Screen=PROD&Store_Code=N&Product_Code=LXH_GTLAT8390-10
needs to be permanently redirected to:
http://www.domain.com/LXH_GTLAT8390-10.html
Basically I need what comes immediately after the words "Product_Code" to become the name of the file.
Thanks for your help
Current URL:
http://www.domain.com/mm5/merchant.mvc?Screen=PROD&Store_Code=N&Product_Code=LXH_GTLAT8390-10
needs to be permanently redirected to:
http://www.domain.com/LXH_GTLAT8390-10.html
Basically I need what comes immediately after the words "Product_Code" to become the name of the file.
Thanks for your help
Try the following in a .htaccess file for the top-level directory:
RewriteCond %{QUERY_STRING} Product_Code=([a-zA-Z0-9_- ]+)
RewriteRule ^mm5/merchant.mvc$ %1.html [R=301]
Let me know if that does not work.
RewriteCond %{QUERY_STRING} Product_Code=([a-zA-Z0-9_-
RewriteRule ^mm5/merchant.mvc$ %1.html [R=301]
Let me know if that does not work.
ASKER
RewriteCond %{QUERY_STRING} Product_Code=([a-zA-Z0-9_- ]+)
RewriteRule ^mm5/merchant.mvc$ %1.html [R=301]
This works great but it copies the query string. How do I stop it from copying the query string?
RewriteRule ^mm5/merchant.mvc$ %1.html [R=301]
This works great but it copies the query string. How do I stop it from copying the query string?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That did it! Thank you.
Does it show the question mark, or is Apache smart?
ASKER
Apache is smart. It does not show the question mark.
Excellent. (Cue Mr. Burns' finger-tremble.)
Redirect the long domain to the short (guessing so) If so then
RewriteEngine On
RewriteRule ^merchant\.mvc.*Product_Co
Or the short to the long which would be
RewriteEngine On
RewriteRule ^(*.)\.html$ /mm5/merchant.mvc?Screen=P