Forum Moderators: phranque
[currentdomain.net...]
[currentdomain.net...]
[currentdomain.net...]
I need to find a way to make it so when people visit links like the above (using the old domain) it redirects to the new domain, like this:
[newdomain.com...]
[newdomain.com...]
[newdomain.com...]
I need it to do this on the fly, since we have thousands of links like the above.
I'm hoping this can be done using .htaccess
Thanks in advance,
-Michael
[edited by: Michael85 at 5:05 am (utc) on Jan. 12, 2009]
Query strings pass unchanged through redirects, unless you take steps to change them. This is because they are data attached to URLs, and not actually part of the URLs. So that simplifies this matter considerably.
A quick look at our forum library, or a search of these forums for "redirect domain" should get you started...
Jim
Make sure that the newdomain.net also redirects to the www version of the new domain.
Make sure the redirect is a 301 redirect, and that you get to the target from any of the starting points in only one hop. That is, make sure that none of the inputs leads to any sort of Redirection Chain.
Edit the .htaccess file of the old domain to include this;
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [newdomain.com...] [R=301,L]:
Is this right?
I would really appreciate it if someone could correct the above, if it's wrong.
Thank you,
Michael
However, why pay for a complete hosting plan just to host a single file with just three lines in it?
I point all of the relevant domains at a single hosting plan, and then add a
RewriteCond to call the redirect only if the "wrong" domain name was called.
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) [newdomain.com...] [R=301,L]:
Thanks in advance,
Michael
[edited by: Michael85 at 2:45 am (utc) on Jan. 13, 2009]
Options +FollowSymLinks
RewriteEngine on
#
# If requested hostname is not [i]exactly[/i] "www.newdomain.com", then redirect to "www.newdomain.com"
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com$
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]
Jim
How would I go about implementing this? My hosting plan allows multiple add-on domains, but when I register the add-on in CPanel, I have the option of where I want to create the folder for the new domain. Do I just point the new add-on domain to /public_html/, which is where my current domain is located?
Thanks again, I really appreciate the help!
Michael
If you point them all to the same filespace, then the above code will redirect all of them to www.newdomain.com
If you point each to its own filespace, then you'll need to add this (or similar) code at the root of each domain's space to do the redirect.
Jim