Welcome to WebmasterWorld Guest from 54.242.94.72

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

From www to no www.

.htaccess mod

     

FuzzyLogik

12:25 am on Jan 4, 2007 (gmt 0)

5+ Year Member



I found this code to turn NON-www into WWW, but I don't want to use www.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ [yoursite.com...] [L,R=301]

How would I make this so that if you go to

[mysite.com...]
it'll go to
[mysite.com?...]

jdMorgan

12:44 am on Jan 4, 2007 (gmt 0)

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



Based on the function you know that it implements, and the domains shown in that example, how do you think it should be modified?

Jim

FuzzyLogik

1:11 am on Jan 4, 2007 (gmt 0)

5+ Year Member



Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.yoursite.com [NC]
RewriteRule ^(.*)$ [yoursite.com...] [L,R=301]

?

That does work somewhat, but when I go to a subdir,
[mysite.com...]

it doesn't change it.

Does that matter for SEO reasons? I think I would prefer it if it changed.

jdMorgan

1:48 am on Jan 4, 2007 (gmt 0)

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



The code, which you coded correctly enough, should work for any file in any subdirectory.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^ww[b]w\.e[/b]xampl[b]e\.c[/b]om [NC]
RewriteRule (.*) http://example.com/$1 [L,R=301]

Literal periods in regular-expressions patterns must be escaped by preceding them with a "\". Otherwise, they take the regular-expressions token meaning of "any single character." Also, it is not necessary to ^start or end$ -anchor a ".*" pattern standing alone. Your code should have worked anyway. So...

If you have not done so already, flush your browser cache (delete IE Temporary Internet Files) before testing any change to your .htaccess code. Otherwise, your browser may show you a response cached before the change, and continue to do so for days, unless you force a page reload or overwrite that cache entry with something newer just by using your browser on other sites.

For more (general) information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].

Jim

 

Featured Threads

Hot Threads This Week

Hot Threads This Month