【问题标题】:Redirect www to non-www using Kohana Framework使用 Kohana 框架将 www 重定向到非 www
【发布时间】:2011-12-15 06:05:32
【问题描述】:

我正在使用 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]

【问题讨论】:

    标签: .htaccess redirect kohana


    【解决方案1】:

    检查您的bootstrap.php。 Kohana::init() 中的 index_file 默认未设置为 FALSE。

    【讨论】:

    • 我已将其设置为 FALSE。当人们使用非 www url 时它工作正常。这是当有人使用它重定向到非 www 的 www 并且然后包含 index.php 文件时引起的。
    猜你喜欢
    • 1970-01-01
    • 2018-06-06
    • 1970-01-01
    • 2011-01-05
    • 2012-10-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多