使用Kohana Framework将www重定向到非www

时间:2011-10-25 19:54:50

标签: .htaccess redirect kohana

我正在使用Kohana安装程序重写index.php以获取干净的URL。我有以下htaccess文件,适用于根域。但是,如果有人试图访问www.domain.com/learn,它将重定向到domain.com/index.php/learn,这是不正确的。它应该重定向到domain.com/learn

# 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]

1 个答案:

答案 0 :(得分:0)

检查bootstrap.phpindex_file中的Kohana::init()默认情况下未设置为FALSE