Redirect www

Justin

Legendary Typer
Joined
Jul 2, 2009
Messages
13,882
Reaction score
1
FP$
106
I do not want visitors to go to the www part of my site. So when they go to www.forumpromotion.net per say, they are redirected instantaneously to forumpromotion.net

How do I do that?
 
In your .htaccess file, add the corresponding code:

Redirect domain.com to http://www.domain.com
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Redirect http://www.domain.com to domain.com
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

Be sure to change domain.com to your actual domain 🙂
 
Good question! Im trying to do the same thing. Its some funky redirection in .htaccess that I always spend hours being baffled by.

Thanks dotDavid, now I see why you are a valued contributor!

Off to do that now!
 
khaleel said:
Don't you have cpanel
If yes just use the redirect section from there
Does the same thing; redirect just edits the .htaccess, ie. the exact same thing as my code.
 
khaleel said:
Don't you have cpanel
If yes just use the redirect section from there
Yes, I know Cpanel can do that, however I wanted to know how to do it manually that way if something messes up or I don't have cpanel.
Thanks David, + Rep
 
khaleel said:
I know but it just much more quicker
If you do things the easy way then you don't really learn anything 😉

It is like auto mod installers. If you install mods manually, you start to understand the code and how the software works. If you use automod or automatic installers, you don't see the code and you don't really learn anything.
 
Back
Top Bottom