Welcome to WebmasterWorld Guest from 54.227.47.228

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

301 redirect - including www to non-www

     
1:40 am on Feb 16, 2008 (gmt 0)

New User

10+ Year Member

joined:May 11, 2005
posts: 40
votes: 0


Hi,

I just made by decision, after looking carefully at the different opinions I have been given in the [webmasterworld.com...] thread.

What I will do is redirect from
www.example.com to www.example.com/fun.html

My question about this is that I already have a .htacess fille, containing the following:

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]

So if I want to apply correctly the new redirect (from "/" to "fun.html" written above), is this as simple as adding the suggested code?
(RewriteRule ^(index\.html)?$ http://www.example.com/fun.html [R=301,L])

Thanks for the advice.

10:25 pm on Feb 17, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 30, 2003
posts: 932
votes: 0


Sticking my neck out a little...

www.example.com/ to www.example.com/fun.html

# Rewrite "/" to "/fun.html"
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .? /fun.html [L]

Patrick

1:20 am on Feb 18, 2008 (gmt 0)

New User

10+ Year Member

joined:May 11, 2005
posts: 40
votes: 0


Thanks Patrick , it works!

One thing though. I had to add "R=301," at the line "RewriteRule .? /fun.html [L]" so that it becomes
RewriteRule .? /fun.html [R=301,L]

I guess it is the best to have permanent redirect (301) so that the Pagerank of the example.com page gets to the wxample.com/fun.html page.

Does it seems right to you?

Thanks again!

2:54 am on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 29, 2000
posts:12095
votes: 0


It's your site and you can do as you please, but frankly I don't think it's a very good idea at all to have an interior page as the main index page of a site rather than example.com/ or www.example.com/ (with the forward slash).

From the thread you referenced:

Think about the long term health and desirability of your domain. Redirecting to an internal page looks amateurish and isn't what anybody would ever want.

Fully agreed. We can't selectively pick and choose the feedback we take to heart just because it happens agree with what we'd prefer to hear and do.

And long term it could be playing with fire; you can't always depend on search engines getting it 100% right, not immediately or in future. Not only is it totally unconventional, but a lot of directories won't index pages other than the root homepage. And index.html or index.htm should also be 301 directed to the root example.com/ (with the forward slash).

[edited by: Marcia at 2:58 am (utc) on Feb. 18, 2008]

8:29 am on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 30, 2003
posts: 932
votes: 0


Shrike99,

As jdMorgan pointed out in response to my question in another thread, this should work too:

Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
#
RewriteRule ^$ /fun.html [L]
#

Regarding Marcia's comment, surely http://www.example.com/ is what will appear in the browser address bar, not http://www.example.com/fun.html - because this is a "hidden" Rewrite, not a redirect. And there's no need for R=301.

I don't see the purpose of this exercise, though.

[edited by: Patrick_Taylor at 8:36 am (utc) on Feb. 18, 2008]

9:02 am on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 29, 2000
posts: 12095
votes: 0


I don't see the purpose of this exercise, though.

Patrick, the purpose is to control the flow of PageRank, since it's the fun.html page that apparently gets most of the inbound links.

Regarding Marcia's comment, surely http://www.example.com/ is what will appear in the browser address bar, not http://www.example.com/fun.html - because this is a "hidden" Rewrite, not a redirect. And there's no need for R=301.

So then: Given that this is all about PageRank, and requests for fun.html will serve user agents www.example.com/ (including browsers and Googlebot) when fun.html is requested, then what does Google do with the PageRank, since PR is given by URL, which seems now to be mostly going to fun.html?
10:55 am on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 30, 2003
posts: 932
votes: 0


Ahh, okay. I hadn't read the other thread.

So there is the original www.example.com/fun.html with lots of inbound links (and this URL will appear in the browser when that page is requested) and there is now also www.example.com/ which displays the same content. That's no use at all.

Without going into too much depth, the option is not to Rewrite www.example.com but to 301 redirect www.example.com/fun.html to www.example.com/. But the consensus in the other thread seems to be "leave well alone."

[edited by: Patrick_Taylor at 10:58 am (utc) on Feb. 18, 2008]

11:30 am on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member marcia is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Sept 29, 2000
posts:12095
votes: 0


>>Well, I'll think about it some more, since I break my personal records these days with Adsense, so I don't want to take any chances.

Then why rock the boat?

11:32 am on Feb 18, 2008 (gmt 0)

New User

10+ Year Member

joined:May 11, 2005
posts: 40
votes: 0


Sorry about the confusion Patrick. Here is what my .htaccess file looks right now

RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .? /fun.html [R=301,L]

Does it seems Okay to you?

Marcia, I did not want to pick and choose want I wanted to hear in the [webmasterworld.com...] thread. It looks like there was no best way to do it, and since there are hundred of inbound links pointing to www.example.com/fun.html, I'd rather not risk redirecting them with a 301 to the main page.

But these are not easy decisions... :-(

1:05 pm on Feb 18, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:May 30, 2003
posts: 932
votes: 0


Shrike99, better (technically) would be:

Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
RewriteRule ^$ /fun.html [L]

(See #:3577667 above)

But now, you have www.example.com/fun.html and www.example.com/ with the same content, because this Rewrites the homepage to the "fun" page. The second RewriteRule is not a redirect.

Patrick

[edited by: Patrick_Taylor at 1:07 pm (utc) on Feb. 18, 2008]

11:20 pm on Feb 18, 2008 (gmt 0)

New User

10+ Year Member

joined:May 11, 2005
posts:40
votes: 0


Hi, thanks for the help Marcia and Patrick.

Marcia, the reason I want to do this is because I'm redesigning the site right now, and I plan to ship some t-shirts to bloggers to advertise the new "version". And I'd rather have "example.com" on the t-shirt instead of "example.com/fun.html".

Patrick, you wrote: "The second RewriteRule is not a redirect." Is it my second RewriteRule thats is not a redirect (RewriteRule .? /fun.html [R=301,L] ) ? What I want are 301 redirects, to control the flow of PageRank.

Marcia, following your comment ##:3577530 , I also added the following line:
Redirect 301 /index.html http://www.example.com/fun.html
It was needed since www.example.com/index.html was not 301 to the http://www.example.com/fun.html page. Thanks.

So, here is my .htaccess right now:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*) http://www.example.com/$1 [R=301,L]
RewriteCond %{REQUEST_URI} ^/$
RewriteRule .? /fun.html [R=301,L]
Redirect 301 /index.html http://www.example.com/fun.html

Knowing that I want to send the PageRank from example.com to example.com/fun.html, does it seems OK to you?

Thanks again for your help.

Shrike99

12:00 am on Feb 19, 2008 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


Put the rules in order from most-specific to least-specific to avoid multiple sequential redirects for a single non-canonical request, and do not mix mod_alias and mod_rewrite directives, so that you can control order of execution. I also optimized the code to eliminate unnecessary and/or redundant directives.

RewriteEngine on
RewriteBase /
#
# Redirect requests for "/index.html" and "/" to www.example.com/fun.html
RewriteRule ^(index\.html)?$ http://www.example.com/fun.html [R=301,L]
#
# Redirect all remaining requests for any resources in example.com to www.example.com
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

Jim
3:34 am on Feb 19, 2008 (gmt 0)

New User

10+ Year Member

joined:May 11, 2005
posts:40
votes: 0


I just put your code in my .htaccess file jdMorgan, and it seems to work just fine.

Thanks!

[edited by: Shrike99 at 3:38 am (utc) on Feb. 19, 2008]

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members