Forum Moderators: phranque
I am trying to create a .htaccess file that will allow me to switch the following URL:
domainX.com/Merchant2/merchant.mvc?
to
domainY.com/Merchant2/merchant.mvc?
Anything that has that string in it I would like forward, but anything that does not I would like to remain the same.
So for example,
domainX.com/Merchant2/merchant.mvc?storeurl&sample1=432
to
domainY.com/Merchant2/merchant.mvc?storeurl&sample1=432
But if someone simply goes to: domainX.com or domainX.com/url.html it should stay at domainX.
Another issue I'm having is when I save .htaccess file in notepad, it does not convert correctly. I can't even upload it correctly to my server. Do I need a special editor or is there a special way to save it?
My hosting company gave me the below .htaccess file, but I don't know if it works and it redirects everything ... rather than just the particular strings I would like redirected:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} www.domainX.com RewriteRule (.*) [domainY.com...] [R=301,L]
Also would like this to work for both "www" and without "www"
* Any help would be greatly appreciated!
I haven't been able to get the file to work ...
Not sure why.
I did:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?domainX\.com
RewriteCond %{Merchant2/merchant.mvc*} .
RewriteRule (.*) [domainY.com...] [R=301,L]
I also tried:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?domainX\.com
RewriteCond %{http://domainX.com/Merchant2/merchant.mvc*} .
RewriteRule (.*) [domainY.com...] [R=301,L]
I tried multiple other variations of the above and it does not do anything. What am I doing wrong?
The query string I am trying to effect is "Merchant2/merchant.mvc" -- any time this string is in the domainX URL, I would like the URL changed to DomainY but keep all the rest of the URL string the same.
Should I be putting astrics in there somewhere in the query? I even tried that. Can't get it to work.
Help is greatly appreciated!
Code for use in domainX/.htaccess:
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?domainX\.com
RewriteRule ^Merchant2/merchant\.mvc$ http://www.domainY.com/Merchant2/merchant.mvc [R=301,L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^(www\.)?domainX\.com
RewriteRule ^merchant\.mvc$ http://www.domainY.com/Merchant2/merchant.mvc [R=301,L]
Terminology: Note that "Merchant2/merchant.mvc" is the local URL-path, and "storeurl&sample1=432" is a query string. The "?" delimits the URL-path from the query string, and is part of neither.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim