Reputation: 2274
I have this code in the .htaccess-file of my root:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
This changes mysite.com
into www.mysite.com
.
I've put the same .htaccess-file inside a folder named "v2". I want mysite.com/v2/start.php
to change to www.mysite.com/v2/start.php
. This doesn't happen, although other resources claim it should work.
Anyone has any idea what I am doing wrong?
Upvotes: 2
Views: 1179
Reputation: 519
Try this:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Upvotes: 4