Jump to content

Force Www On Domain Using Htaccess


driz

Recommended Posts

Hi, I use a .htaccess file on one my websites that forces all www.domain.com to domain.com

RewriteEngine OnRewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]RewriteRule ^(.*)$ http://%1/$1 [R=301,L]RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^(.+) - [PT,L]RewriteRule ^(.*) index.phpAddHandler php5-script .php

Well ironically I have website that needs the exact opposite. If a user was to go to domain.com it auto force www.domain.comI don't understand HTACCESS at all, so any help would be very much appreciated. Thanks

Link to comment
Share on other sites

You could try this:

RewriteEngine OnRewriteCond %{HTTP_HOST} ^www.example.com [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]RewriteCond %{REQUEST_FILENAME} -f [OR]RewriteCond %{REQUEST_FILENAME} -dRewriteRule ^(.+) - [PT,L]RewriteRule ^(.*) index.phpAddHandler php5-script .php

Link to comment
Share on other sites

The "www" is nothing more than a re-direct to the public, web-accessible portion of your Hosting Account.There is no need to force the inclusion of the "www" in your URL's. In fact, there is a move to drop the requirement from the process, so it is not really a wise decision, in my opinion, to do what you are doing.

Link to comment
Share on other sites

The "www" is nothing more than a re-direct to the public, web-accessible portion of your Hosting Account.There is no need to force the inclusion of the "www" in your URL's. In fact, there is a move to drop the requirement from the process, so it is not really a wise decision, in my opinion, to do what you are doing.
Most websites do. For example try http://apple.com/ see how it automatically adds the WWW back on the url. same with Facebook. This is what I'm trying to do. Thanks.
Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...