View Full Version : htaccess 301 Redirect
ijumper
07-05-2010, 11:03 AM
How to implement the non www to www 301 Redirect in ht access? I'm trying to create it, but still I have some concerns. I dont know exactly in which line I'm supposed to put the code.
Here what I have, but still not sure that it is good for hostmonster servers. Any help will be appreciated. Thanks.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^example\.com
RewriteRule (.*) http://example.com/$1 [R=301,L]
Falcon1986
07-05-2010, 07:34 PM
First of all, HostMonster has disabled '+FollowSymLinks' for security reasons. Here is what you can use instead with the .htaccess rules required for what you want:
Options +SymLinksIfOwnerMatch
RewriteEngine On
# Redirect all non www requests to www alternative
RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1%{REQUEST_URI} [R=301,L]
ijumper
07-15-2010, 02:06 AM
Thanks. I did it, but when I type the domain name in the address bar without WWW, it does not displays it with WWW.
Or maybe I'm missing something?
shadmego
07-15-2010, 07:43 AM
Try this:
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.askapache\.com$ [NC]
RewriteRule ^(.*)$ http://www.askapache.com/$1 [R=301,L]
ijumper
07-16-2010, 08:58 PM
I've uploaded the code below to the server, but it displayed internal server error, or may be I put something wrong in the code?
# Redirect all non www requests to www alternative
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.inflatablejumperrentals\.com$ [NC]
RewriteRule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [R=301,L]
Falcon1986
07-16-2010, 09:31 PM
Do you have any other rewrite rules in your .htaccess file?
Try both methods, but with 'Options +SymLinksIfOwnerMatch'; not 'Options +FollowSymlinks'.
BTW, when you used the rule I suggested, did you remember to change example.com to your own domain name? Furthermore, this rule should be at the very top of your .htaccess file.
shadmego
07-17-2010, 12:08 AM
You should also have only one instance of
RewriteEngine On
RewriteBase /
Multiple instances of these lines will cause your site to break.
ijumper
07-17-2010, 01:00 AM
I did some online research and here what I've got
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^inflatablejumperrentals [nc]
rewriterule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [r=301,nc]
Its working fine I hope it wont affect on search engine rankings.
Thank you Falcon1986 and shadmego, I appreciate your help.
Falcon1986
07-18-2010, 09:45 PM
I did some online research and here what I've got
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^inflatablejumperrentals [nc]
rewriterule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [r=301,nc]
Its working fine I hope it wont affect on search engine rankings.
Thank you Falcon1986 and shadmego, I appreciate your help.
Thanks for the update!
Is the 3rd line correct or did you forget to add the .com to your domain name?
Options +FollowSymlinks
RewriteEngine On
rewritecond %{http_host} ^inflatablejumperrentals.com [NC]
rewriterule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [R=301,NC]
ijumper
07-21-2010, 01:52 AM
Thanks for your research, the topic is turning to a really hot one, which means that we can develop more network skills.
I did the ht access like this:
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^inflatablejumperrentals [nc]
rewriterule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [r=301,nc]
I did not put .com in the third line, now is 2 late tomorrow I will try to check you researched option.
The same time I've noticed that because of the redirect the PR dropped down from 26 to 18. What you think about it?
ijumper
07-21-2010, 03:18 PM
Falcon you were right
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^inflatablejumperrentals.com [nc]
rewriterule ^(.*)$ http://www.inflatablejumperrentals.com/$1 [r=301,nc]
The code has to have a .com on the third line of it. I am wondering, how it come? Before it was working normal with no problems, but today it displayed Error.
Taylor08
07-22-2010, 06:17 PM
Actually it shouldnt have worked before. So I take it the site is now being redirected properly? Btw, changes like this and tinkering with htaccess doesnt usually result in quick actions by Google. It always waits a while to see what pans out because Google is aware of mistakes or accidents being done by webmasters or servers. I dont think you could have dropped 8 ranks because of something like this. That usually takes different factors, but who knows.
----------------------------------------------------
“The greatest barrier to success is the fear of failure.” - Sven Goran Eriksson
Check out my USB Flash Drive (http://www.usbmemorysticks.net) Blog.
Falcon1986
07-22-2010, 08:20 PM
Google doesn't crawl your website every minute by default.
Furthermore, one of the tips I read long ago when it came to SEO was to decide from the get-go whether you wanted a www- or non-www URL because it can influence how your sites fall in search engine results.
Now that you have set up this redirect, you should go through any links on your site and edit them to reflect this change.
ijumper
07-27-2010, 12:35 AM
Thanks Falcon,
You provided a great help to me.
midwestalice
08-30-2010, 09:25 AM
Is this how you change the redirect option for a site? I am having trouble because I am trying to begin transferring a domain while leaving the site where the way it is until it's ready to change the nameservers. I tried contacting the hostmonster support for this, and they said they think I need to change the redirect.php file. However, when I deleted it, that did not appear to change anything. So, I was wondering if you change this .htaccess in order to get the site to redirect to a new IP address.
If so, how would I go about doing this? Thanks!
-Brittany
midwestalice
08-30-2010, 03:11 PM
I got my problem resolved. Thanks anyway.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.