我的.htaccess文件中有以下规则,我想知道如何将我的URL从www.mydomain.com重写为mydomain.com,我正在使用Kohana 3.2并且没有找到有关它的信息。
RewriteEngine On
RewriteBase /
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT]
我尝试了以下内容:
RewriteEngine On
RewriteBase /
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ http://mydomain/$1 [L,R=301,NC]
RewriteRule .* index.php/$0 [PT]
但它导致“太多重定向”
答案 0 :(得分:0)
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%2://%1%{REQUEST_URI} [L,R=301]