Page 1 of 1

Moving domain, 301 redirect proper config Joomla

Posted: Tue Jan 31, 2012 7:42 pm
by jslost
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!

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jan 31, 2012 8:11 pm
by Markstein
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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jan 31, 2012 11:25 pm
by jslost
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!

Re: Moving domain, 301 redirect proper config Joomla

Posted: Thu Feb 02, 2012 1:11 am
by Markstein
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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Fri Feb 03, 2012 11:41 pm
by jslost
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?

Re: Moving domain, 301 redirect proper config Joomla

Posted: Sat Feb 04, 2012 7:05 pm
by Markstein
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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Thu Feb 09, 2012 8:10 pm
by jslost
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.

Re: Moving domain, 301 redirect proper config Joomla

Posted: Fri Feb 10, 2012 12:16 am
by jslost
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!

Re: Moving domain, 301 redirect proper config Joomla

Posted: Wed Feb 15, 2012 2:44 am
by rakicko
Big thanks for help..i put in wrong place..and then redict just to home page..now working great!!! thanks!

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Mar 13, 2012 2:11 pm
by hankin
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.

Re: Moving domain, 301 redirect proper config Joomla

Posted: Wed Mar 14, 2012 11:26 am
by hankin
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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Mar 27, 2012 9:27 am
by Pete_Evans
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!

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jun 05, 2012 6:35 pm
by pinkkotten
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?

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jun 05, 2012 7:21 pm
by Markstein
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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Thu Oct 04, 2012 7:38 am
by quoclong5

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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Wed Oct 09, 2013 4:24 pm
by pishro
please see this link about: Redirection

Code: Select all

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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Oct 15, 2013 12:05 pm
by migors
how to replace 303 language redirect from domain.com to domain.com/en to 301?

i really need help, but no answers

Re: Moving domain, 301 redirect proper config Joomla

Posted: Mon Jun 30, 2014 6:50 pm
by katerina_s
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 :-)

Re: Moving domain, 301 redirect proper config Joomla

Posted: Mon Jun 30, 2014 10:09 pm
by dpacadmin
Make sure you have a

Code: Select all

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

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jul 01, 2014 6:08 am
by katerina_s
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?

Re: Moving domain, 301 redirect proper config Joomla

Posted: Tue Jul 01, 2014 6:15 am
by dpacadmin
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