.htaccess - Rewrite individual URLs to one URL with GET parameter
I have a list of domains that are specific to individual products, such as
GreatProduct.com SomeOtherProduct.com SomeCustomProduct.com etc.I want to now redirect these so that they will point to
mydomain.com/products/allproducts.php?prod=ABCD?type=STAND
mydomain.com/products/allproducts.php?prod=ABGH?type=STAND mydomain.com/products/allproducts.php?prod=ABGH?type=CUSTOM etc.(I know there should be "http://www. in front of these, but I'm restricted from posting more than two links)
I am now pointing each domain to a separate root directory, so I intend to place a different .htaccess into each domain's root.
So far, I'm able to use .htaccess to send eac开发者_JAVA百科h domain to mydomain.com/products/allproducts.php, but the parameters are not working properly.
This .htaccess,
redirectMatch 301 ^(.*)$ http://www.mydomain.com/products/allproducts.php%3fprod=ABCD%26type=SAME
redirectMatch permanent ^(.*)$ http://www.mydomain.com/products/allproducts.php%3ftwn=ABCD%26type=SAME
results in
mydomain.com/products/allproducts.php%253prod=ABCD%2526type=SAME
I've found lots of examples of turning a paramter-based URL into one without, but nothing like this!
Thanks!
@user643373
Does this have to be in an .htaccess
file?
mod_rewrite
might provide a solution for this:
RewriteEngine On
RewriteCond "%{HTTP_HOST}" "!allproducts"
RewriteCond "%{HTTP_HOST}" "^(?:www\.)?([^.]+)\.com" [NC]
RewriteRule "(.*)" "http://mydomain.com/products/allproducts.php?prod=%1&type=SAME" [QSA,R=301,L]
I don't know what you want to do with the STAND
, SAME
, and CUSTOM
bits..
精彩评论