【发布时间】:2015-11-06 03:10:01
【问题描述】:
我的 .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]
但这会导致“重定向过多”
【问题讨论】:
-
你正在寻找这样的东西:
RewriteCond %{HTTP_HOST} ^www\.RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]。
标签: php apache .htaccess mod-rewrite kohana