301 permanent redirect

Status
Not open for further replies.

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
The solution to domain name change without affecting the search engine is 301 permanent redirect. It is recommended by google itself.

My case is this

I have a domain olddomain and want to change it to new domain newdomain without affecting search engines. Host is same

Here is the catch

olddomain is primary domain
newdomain is parked domain

now when i give this in .htaccess it is showing that "This page is permanently moved to here"

"here" has the link which is current newdomain page. Means it is redirecting to new domain but it is showing the above statement. So it is going like a loop.

Code:
RewriteEngine on
RewriteRule ^(.*)$ http://newdomain/$1 [R=301,L]

So can somebody resolve this issue please.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Are both domains hosted out of the same directory on your account?

If your .htaccess file is being loaded for both newdomain and olddomain, then it's going to be a redirect loop. But if you do this:

/home/username/public_html/ (new domain here)
/home/username/public_html/old (old domain here with .htaccess file)

It should work
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
Yes,

I told you already that olddomain is Primary domain points to public_html
newdomain is parked means it also points to public_html

I can't move the data to other folder because it affects the search engines.

If i don't bother all these things the I would have directly changed the primary domain to another one. :)
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
Moving the folder does not move the location in the url.

For example, I could set my account to have foo.com as the primary domain, located at /home/garrett/public_html and have bar.com as an addon at /home/garrett/public_html/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p and it will have no problem. the addon domain can be located in any folder. You just have to change the document root.

You could try this instead:

Code:
RewriteCond %{HTTP_HOST} ^olddomain\.com$ [NC]

Put this just before your RewriteRule. I thought it would be easier to just change the setting in your CPanel, but editing the .htaccess is an option if you feel comfortable.
 
Last edited:

descalzo

Grim Squeaker
Community Support
Messages
9,373
Reaction score
326
Points
83
You want to redirect only the requests for the old domain.
So you need a rewrite condition.
Maybe try something along the lines of:

Code:
[COLOR=black]RewriteEngine On[/COLOR]
[COLOR=black]RewriteCond %{HTTP_HOST} ^olddomainname\.com$[/COLOR]
[COLOR=black]RewriteRule (.*) http://www.newdomainname.com/$1 [R=301,L[/COLOR][COLOR=black]][/COLOR]
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
Moving the folder does not move the location in the url.

For example, I could set my account to have foo.com as the primary domain, located at /home/garrett/public_html and have bar.com as an addon at /home/garrett/public_html/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p and it will have no problem. the addon domain can be located in any folder. You just have to change the document root.

You could also modify your .htaccess using rewrite rules, but I thought it would be simpler to just move the physical location :D


In the previous post you told in REVERSE

Code:
/home/username/public_html/ (new domain here)
/home/username/public_html/old (old domain here with .htaccess file)

This is what you told.

My site is at root of the primary domain and another one i added as parked domain

If i have to add as addon domain it will create the subdomain for the primary domain. And I have to make a exact copy of the main site in the addon domain folder and it will do the 301 permanent redirect to the newdomain.

This I know, Any other solution than this. Means making another copy of site and redirecting and when making copy i have to change each and every link in the mysql to new one. This is tedious job. If any other solution is not there, I will go with this one.



EDIT

@descalzo : Yeah Condition may work but let me try.
I will tell you the result :)
 
Last edited:

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
It doesn't matter which is the addon.

Either way, why don't you try the RewriteCond first, I think that will be easier if you're alright with it.
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
It worked with condition. After some trial and error it is working fine.

Anyway I have to check all the links for next week. Thanks for help guys.
 

garrettroyce

Community Support
Community Support
Messages
5,609
Reaction score
250
Points
63
No problem, sorry for the confusion with the addons ;)
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
No problem, sorry for the confusion with the addons ;)

No Problem. After posting here only I got an idea that I can use the rewrite condition. This is one of the advantage for me with this conversation. Thanks to all for help. :)
 
Last edited:
Status
Not open for further replies.
Top