Removing www from TLD

Discuss practical ways rearrange URLs using mod_rewrite.

Removing www from TLD

Postby cyomega » Mon Jan 31, 2005 8:49 am

I have a domain, for example http://www.example.com/
I would like to have any requests for www.example.com to be redirected to http://example.com

I have this:
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} example\.com
RewriteRule ^(.*) http://example.com/$1 [R]

and there are no errors, but when I go to www.example.com, that address still shows up in the address bar. What kind of flags do I need to pass in order for the www to completely disappear?
cyomega
 

Postby Caterham » Mon Jan 31, 2005 10:19 am

if this does not work
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule ^(.*) http://example.com/$1 [R=301,L]
you are not allowed to use mod_rewrite in .htaccess files. Test also viewtopic.php?p=1841#1841

Ask your provider, if
Code: Select all
AllowOverride FileInfo
and
Code: Select all
Options +FollowSymLinks
can be enabled for you.

Bob
Last edited by Caterham on Sun Apr 10, 2005 5:05 am, edited 1 time in total.
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm

Postby volknet » Wed Feb 02, 2005 8:24 am

Will you ever be penalized by google for using a 301 redir?
volknet
 

Postby Caterham » Wed Feb 02, 2005 9:54 am

no, see google webmaster FAQ
Caterham
 
Posts: 690
Joined: Fri Dec 10, 2004 1:30 pm


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 48 guests

cron