How to redirect from domain.com to www.domain.com

silis25

Member
Jul 7, 2011
7
0
51
Hi,

I need your assistance in redirecting my domain properly.

Problem: My domain 'letthemstare.com' doesn't redirect to 'www.letthemstare.com'

'www.letthemstare.com' - Works
'letthemstare.com' - Fails

1. My site is located within a folder named fashionblog.
2. I modified my httpd.conf through "Pre VirtualHost Include" as follows:

<Directory /home/letthems/public_html>

# Turn on rewrites.
RewriteEngine on

# Only apply to URLs on this domain
RewriteCond %{HTTP_HOST} ^(www.)?letthemstare.com$

# Only apply to URLs that aren't already under folder.
RewriteCond %{REQUEST_URI} !^/fashionblog/

# Don't apply to URLs that go to existing files or folders.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all those to insert /fashionblog.
RewriteRule ^(.*)$ /fashionblog/$1

# Also redirect the root folder.
RewriteCond %{HTTP_HOST} ^(www.)?letthemstare.com$
RewriteRule ^(/)?$ fashionblog/index.php [L]

</Directory>

The above redirects most of the things properly but letthemstare.com redirection still doesn't work.

4. Also, I don't understand why

RewriteCond %{HTTP_HOST} ^letthemstare.com$

doesn't redirect my domain (I've tried that)

I will appreciate your help here.

Kfir Silis
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
somewhere over the rainbow
cPanel Access Level
Root Administrator
Have you tried simply putting in an .htaccess file in /home/username/public_html/.htaccess location with these rewrites? There's no real reason to use an include for these. You might try the following instead for that redirection:

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

mambovince

Well-Known Member
Jan 15, 2005
193
0
166
London, UK
More simple way will be to add this redirect via cpanel's Redirect menu :)
I am surprised cPanel does not yet include a simple option to do this yet.

BTW
is there any difference on how to write that last rule:
RewriteRule (.*) http://www.letthemstare.com/$1 [R=301,L]
I was previously told this way
RewriteRule (.*) http://www.letthemstare.com/$1 [L,R=301]

Thanks
 
Last edited:

Lyttek

Well-Known Member
Jan 2, 2004
775
5
168
I'm going to ask a silly question here: is 'letthemstare.com' supposed to point to the exact same content as 'www.letthemstare.com'?? If so, and your DNS is setup correctly, all you need is a simple redirect configured in the cpanel redirect section...

Edit: it looks like it's working when I visit the site, assuming I'm supposed to see some rather hottish pics ;-)
 
Last edited: