olechafm
olechafm

Reputation: 131

.htaccess all to index + www to non-www

I have a simple .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule (.*) index.php/$1 [L]

and now would like to add redirect from all www cals to non www

how to combine it with my file?

Upvotes: 0

Views: 86

Answers (2)

Jon Lin
Jon Lin

Reputation: 143906

Add this to the top of your file (right below RewriteEngine On:

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

Upvotes: 0

Joe Conlin
Joe Conlin

Reputation: 5994

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php/$1 [L]

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

Upvotes: 1

Related Questions