.htaccess所有索引+ www到非www

时间:2014-10-14 17:36:35

标签: .htaccess redirect

我有一个简单的.htaccess文件

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

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

现在想要将所有www cals的重定向添加到非www

如何将它与我的文件结合使用?

2 个答案:

答案 0 :(得分:1)

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]

答案 1 :(得分:0)

将其添加到文件顶部(RewriteEngine On下方

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