1
我正在使用Kohana設置來爲乾淨的URL重寫index.php。我有以下htaccess文件,它適用於根域。但是,如果有人試圖去www.domain.com/learn,它將重定向到domain.com/index.php/learn,這是不正確的。它應該重定向到domain.com/learn使用Kohana框架將www重定向到非www使用Kohana框架
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase/
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
#RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
#Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www.ericleslie.com [NC]
RewriteRule ^(.*)$ http://ericleslie.com/$1 [L,R=301]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
我將它設置爲FALSE。當人們使用非www網址時,它工作正常。這是由於某人使用重定向到非www的www而導致的,然後包含index.php文件。 – EricLeslie