Sam
Sam

Reputation: 14596

apache rewrite rule to add www

I've added a rule to force www in front of my domain name:

browsing to mysite.fr redirects to www.mysite.fr//

why does it add two slashes at the end of the URL ?

Here's my full rewrite rules set:

<IfModule mod_rewrite.c>
RewriteEngine On  

Rewritecond %{HTTP_HOST} !^www\.mysite\.fr
RewriteRule (.*) http://www.mysite.fr/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]

RewriteRule ^/css(/|$) - [L,NC]
RewriteRule ^/img(/|$) - [L,NC]
RewriteRule ^/js(/|$) - [L,NC]

# Rewrite all other queries to the front controller.
RewriteRule .? %{ENV:BASE}/app.php [L]

</IfModule>

Upvotes: 0

Views: 1012

Answers (1)

user1646111
user1646111

Reputation:

Try this one, (its not tested)

RewriteRule ^/(.*)$ http://www.mysite.fr/$1 [R=301,L]

Upvotes: 1

Related Questions