digitalpixelpro
digitalpixelpro

Reputation: 139

.htaccess non-www redirect creating error 404?

Error: The requested URL /public_html/ was not found on this server.

Instead of going to http://www.mywebsite.com/, my 301 redirect in the .htaccess file is sending the browser to http://www.mywebsite.com/public_html/ and throwing that error.

This may have something to do with the fact that I am hosting an add-on domain in a subdirectory? The issue only comes up when using InMotion.com hosting, the same code works fine on a page I am hosting on Bluehost.

.htaccess code:

Options +FollowSymlinks
RewriteEngine On
RewriteCond %{http_host} ^mywebsite.com [NC]
RewriteRule ^(.*)$ http://www.mywebsite.com/$1 [R=301,L]

Upvotes: 2

Views: 1331

Answers (1)

quentinxs
quentinxs

Reputation: 866

This has always worked for me. (Note the backslash before ".com")

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

Upvotes: 2

Related Questions