在域名[Kohana]

时间:2015-10-23 11:26:24

标签: .htaccess url mod-rewrite kohana

我在Kohana框架中遇到了网址问题。

当我键入mydomain.xyz/admin重定向到mydomain.xyz//admin并从Kohana核心返回一些错误时。

以下是我.htacces的一部分:

RewriteEngine On
RewriteBase /

RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media)
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?kohana_uri=$1 [L]

###### Add trailing slash (optional) ######
RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$
RewriteRule ^(.*)$ $1/ [R=301,L]

RewriteRule ^(.*)public_html/index.php/(.*)$ http://mysite.xyz/$1$2 [R=301,L]

从其他服务器移动网站后出现了这个问题。

1 个答案:

答案 0 :(得分:1)

这样做:

DirectorySlash Off
RewriteEngine On
RewriteBase /

###### Add trailing slash (optional) ######
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [L,R=301,NE]

RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^(.*)public_html/index.php/(.*)$ /$1$2 [R=301,L,NE]

RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media)
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?kohana_uri=$1 [L,QSA]

确保在测试此更改之前清除浏览器缓存。