Moving domain, 301 redirect proper config Joomla

Discuss Search Engine Optimization in relation to Joomla!. This forum will also have discussions on SEF/SEO Joomla! extensions.

Moderator: General Support Moderators

Locked
jslost
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 09, 2009 11:21 pm

Moving domain, 301 redirect proper config Joomla

Post by jslost » Tue Jan 31, 2012 7:42 pm

Hello. We recently acquired a new domain for our site and need to formally change it now for SEO reasons. Currently the new domain is active on our hosting account and the old domain is parked. Google results still show up and lead to our old domain. Since the domain is parked no redirect is happening.

I have read that the search engines don't like this and that I need to setup permanent 301 redirects form the old pages to the new ones. I tried to setup redirects in Cpanel but the .htaccess file would not accept the Joomla php pages. There is a wealth of info on this but not specific to Joomla. I just want to make sure that before I submit the formal change to Google I have it setup right.

Does anyone know the proper way to configure this? I am open to removing the domain from it's parked status if it would help. Thanks!

Markstein
Joomla! Hero
Joomla! Hero
Posts: 2268
Joined: Sat Feb 09, 2008 8:27 am
Location: California, USA

Re: Moving domain, 301 redirect proper config Joomla

Post by Markstein » Tue Jan 31, 2012 8:11 pm

You can use this code (replacing the example.com's with your own domain)

Code: Select all

########## Begin - 301 Redirect
#
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.example.com/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
#
########## End - 301 Redirect
Note that the code above will redirect all requests where the hostname part of the request is not "exactly" http://www.example.com

That takes care of requests for other subdomains and requests for other domains as well as upper case requests and requests with unwanted port numbers. It will also force 'www' into the URL.

The above code was provided by a user named g1smd. More info:

http://forum.joomla.org/viewtopic.php?f ... 9#p2513459

Place the code in your joomla .htaccess file in the correct location:

Code: Select all

## Begin - Custom redirects
#
# If you need to redirect some pages, or set a canonical non-www to
# www redirect (or vice versa), place that code here. Ensure those
# redirects use the correct RewriteRule syntax and the [R=301,L] flags.
#
## End - Custom redirects
Place the code directly above ## End - Custom redirects.

Mark

jslost
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 09, 2009 11:21 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by jslost » Tue Jan 31, 2012 11:25 pm

Thanks for your help. I tried that but it didn't seem to have any effect. There was no Custom Redirects section so I added it.

A copy of my htaccess is attached. This might be stupid question, but I needed to put my NEW domain to replace exampledomain correct? Also, I have an .htaccess file in both my root and public_html directory. I used the one in the public_html directory as that is where joomla is. I'm guessing that is correct.

Could the problem be related to the fact that the old domain is parked at the webhost in the same Cpanel account??

Thank you!
You do not have the required permissions to view the files attached to this post.

Markstein
Joomla! Hero
Joomla! Hero
Posts: 2268
Joined: Sat Feb 09, 2008 8:27 am
Location: California, USA

Re: Moving domain, 301 redirect proper config Joomla

Post by Markstein » Thu Feb 02, 2012 1:11 am

What version of Joomla are you running?

Starting with Joomla 1.5.23 (I believe) the Custom redirects section was in the htaccess file by default. You should be running Joomla 1.5.25 if on j1.5.

Mark

jslost
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 09, 2009 11:21 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by jslost » Fri Feb 03, 2012 11:41 pm

It looks like were running 1.5.22. Could that be the problem? I'll upgrade as needed but even after adding the custom redirects manually it still didn't work...any ideas? Did I configure my htaccess file correct based on what you could see?

Markstein
Joomla! Hero
Joomla! Hero
Posts: 2268
Joined: Sat Feb 09, 2008 8:27 am
Location: California, USA

Re: Moving domain, 301 redirect proper config Joomla

Post by Markstein » Sat Feb 04, 2012 7:05 pm

Being on version 1.5.22 would not be the problem however I would advise that you update to version 1.5.25 ASAP. You should also use the htaccess file from the newer version so you'll need to grab the htaccess.txt from the full package.

You could also contact your host and tell them what you are trying to do. If you have cPanel you have the option to point parked domains to other domains I believe. The above code "should" work though. I use it myself on a site that has 5 domains that all go to the same site. Using the code above redirects all the domain names to a single domain name.

Mark

jslost
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 09, 2009 11:21 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by jslost » Thu Feb 09, 2012 8:10 pm

Thank you! I will proceed as you mentioned, first upgrading to 1.5.25.

Last question, in your configuration do you have your domains parked in the same hosting account or simply pointed to the same server?

I'm starting to thing the parking is what is causing the problem. Perhaps the pages are getting found and therefore not picked up by the .htaccess file to forward...just an idea.

jslost
Joomla! Apprentice
Joomla! Apprentice
Posts: 6
Joined: Mon Nov 09, 2009 11:21 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by jslost » Fri Feb 10, 2012 12:16 am

Update* RESOLVED

Just in case anyone also has this issue, the redirects work fine once Joomla is upgraded to 1.5.25, even with the domain parked.

Thanks again Markstein for your help!

rakicko
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 144
Joined: Sun Mar 07, 2010 4:01 pm
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by rakicko » Wed Feb 15, 2012 2:44 am

Big thanks for help..i put in wrong place..and then redict just to home page..now working great!!! thanks!

hankin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Thu Mar 08, 2012 2:40 pm
Location: England
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by hankin » Tue Mar 13, 2012 2:11 pm

The code works well even on Joomla 1.5.23 so long as you edit it correctly and change "example.com" with your domain name. This occurs 4 times.

hankin
Joomla! Apprentice
Joomla! Apprentice
Posts: 21
Joined: Thu Mar 08, 2012 2:40 pm
Location: England
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by hankin » Wed Mar 14, 2012 11:26 am

Hey guys, if you change the custome 301 redirect in your .htaccess file the code on this page provided by gs1md and webdongle is great: http://forum.joomla.org/viewtopic.php?f ... 4#p2761454

User avatar
Pete_Evans
Joomla! Apprentice
Joomla! Apprentice
Posts: 32
Joined: Thu Oct 21, 2010 8:15 am
Location: Portsmouth, UK
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by Pete_Evans » Tue Mar 27, 2012 9:27 am

Thanks for all the info in this thread. It has helped me out of a big hole I was in replacing a well established .co.uk domain with a newer .com domain and wanting to pass on the ranking juice on a Joomla 1.5 site. I was going around in circles, but upgrading to 1.525 and then adding the redirect code has done the trick!

pinkkotten
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Jun 05, 2012 6:29 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by pinkkotten » Tue Jun 05, 2012 6:35 pm

Hi guys,
I'd appreciate some help as well. I am very new at this and trying to redirect my old domain but I am not sure how.

I have two active domains in one host package. Currently, they both work as separate domains giving separate links on the website.
How do I make the old domain shift over to the new one?
- In the code provided, which example.com should be the old domain and which should have the new domain?

Markstein
Joomla! Hero
Joomla! Hero
Posts: 2268
Joined: Sat Feb 09, 2008 8:27 am
Location: California, USA

Re: Moving domain, 301 redirect proper config Joomla

Post by Markstein » Tue Jun 05, 2012 7:21 pm

Just replace example.com (making sure you leave all slashes and periods as they are) in all places in the code with your preferred domain. No need to input both.

Mark

quoclong5
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Oct 04, 2012 7:13 am
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by quoclong5 » Thu Oct 04, 2012 7:38 am

Code: Select all

RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Just replace example.com into your domain. Exp: caunoithanhcong.com redirect to www.caunoithanhcong.com

User avatar
pishro
Joomla! Explorer
Joomla! Explorer
Posts: 301
Joined: Tue Oct 09, 2012 7:22 am

Re: Moving domain, 301 redirect proper config Joomla

Post by pishro » Wed Oct 09, 2013 4:24 pm

please see this link about: Redirection

Code: Select all

http://moz.com/learn/seo/redirection

User avatar
migors
Joomla! Intern
Joomla! Intern
Posts: 70
Joined: Mon Jan 28, 2008 8:56 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by migors » Tue Oct 15, 2013 12:05 pm

how to replace 303 language redirect from domain.com to domain.com/en to 301?

i really need help, but no answers

katerina_s
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jun 30, 2014 6:40 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by katerina_s » Mon Jun 30, 2014 6:50 pm

Hello
I have an old joomla 1.5.24 site and I'm trying to redirect visitors to a new active 2.5 site on the same host. I have applied the above instructions with no result. Could it be that the new site's address is not of the www.example.com type but instead contains several dots and no www?

This is a school website and I am not professional at this, so bear with me and my rather unsophisticated way of describing the situation please :-)

User avatar
dpacadmin
Joomla! Champion
Joomla! Champion
Posts: 6029
Joined: Sat Aug 16, 2008 1:46 pm
Location: the Bat Cave
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by dpacadmin » Mon Jun 30, 2014 10:09 pm

Make sure you have a

Code: Select all

RewriteEngine On
line before your rewrite line or it will not work.

katerina_s
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Mon Jun 30, 2014 6:40 pm

Re: Moving domain, 301 redirect proper config Joomla

Post by katerina_s » Tue Jul 01, 2014 6:08 am

thanks for your reply.
I have the RewriteEngine On in the file, but not right above the redirect part of the code. There is other code in between. Does it matter?

I have also turned the Apache mod rewrite on at my site's back end plus I have renamed the htaccess file to .htaccess (dot added).

Thinking about it I'm afraid the problem is that both sites are built on the same root directory so the old one's address is something like (main address)/old site and the new one's like (main address)/new site.
I mean the first part is the same and the changes are after the slash. Perhaps the redirect works but actually redirects the old site to itself :geek:

Does this sound possible and if so, what else could I try?

User avatar
dpacadmin
Joomla! Champion
Joomla! Champion
Posts: 6029
Joined: Sat Aug 16, 2008 1:46 pm
Location: the Bat Cave
Contact:

Re: Moving domain, 301 redirect proper config Joomla

Post by dpacadmin » Tue Jul 01, 2014 6:15 am

Try using this redirect generator to make your redirect code. Set the type to Apache htaccess. The redirect code needs to be after the rewrite on code but doesn't need to be right after it.
http://www.rapidtables.com/web/tools/re ... erator.htm


Locked

Return to “Search Engine Optimization (Joomla! SEO) in Joomla! 1.5”