0

I have looked around and no one seems to be experiencing the same problem as me.

I have used:

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

However when I navigate to yoursite.com I get taken to www.yoursite.com/public_html which doesn't exist.

Here is my directory structure:

/
| .htaccess
|
| public_html
    |
    |index.php
A-312
  • 10,203
  • 4
  • 38
  • 66
joshkrz
  • 481
  • 3
  • 7
  • 24

2 Answers2

2

Try with this line :

RewriteCond %{HTTP_HOST} !^www\.yoursite\.com$ [NC]

Gumbo in his answer (how to force “www.” in a generic way?) recommanded this structure :

RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Community
  • 1
  • 1
A-312
  • 10,203
  • 4
  • 38
  • 66
0

All you need to do is move the .htaccess file to the public_html folder.

zx81
  • 38,175
  • 8
  • 76
  • 97
  • My htaccess has other directives within it. I have cache control, gzipping and IP blocks. Will any of that break if I move it? – joshkrz Jul 09 '14 at 09:19