简体   繁体   English

从Kohana 2.x中的URL中删除index.php

[英]Remove index.php from URLs in Kohana 2.x

I want to configure Kohana 2.x to have links in this format: 我想配置Kohana 2.x以这种格式的链接:

http://localhost/mysite/web/admin/support

instead of this: 而不是这个:

http://localhost/mysite/web/admin/index.php/support

I removed the index.php from the config.php file ( $config['index_page'] = '';) and I added the following line in the .htaccess file: 我从config.php文件中删除了index.php ( $config['index_page'] = '';)并在.htaccess文件中添加了以下行:

RewriteRule ^(.*)$ /index.php?/$1 [L]

If you hover above a link you can see that the links are like I wanted them but there is always this error: 如果您将鼠标悬停在链接上方,您可以看到链接就像我想要的那样,但始终存在此错误:

Not Found 未找到
The requested URL /mysite/web/admin/support was not found on this server 在此服务器上找不到请求的URL / mysite / web / admin / support

I don't know how to change the configuration like I want to. 我不知道如何改变我想要的配置。

Write following code in htaccess:: 在htaccess中编写以下代码::

RewriteEngine On

RewriteBase /

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

you can also change the config.php file to: 您还可以将config.php文件更改为:

$config['index_page'] = '';

another one try 另一个尝试

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]  

try more solution then see 尝试更多解决方案然后看
How to set up .htaccess for Kohana correctly, so that there is no ugly "index.php/" in the URL? 如何正确设置Kohana的.htaccess,以便URL中没有丑陋的“index.php /”?
see also following tuts:: 另见tuts ::
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM