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

发布于 2024-10-20 04:45:10 字数 519 浏览 0 评论 0原文

我想将 Kohana 2.x 配置为具有以下格式的链接:

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

而不是这样:

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

我从 config.php 文件 ( $config['index_page'] = '';) 并且我在 .htaccess 文件中添加了以下行:

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

如果将鼠标悬停在链接上方,您可以看到链接就像我想要的那样,但总是出现此错误:

未找到
在此服务器上找不到请求的 URL /mysite/web/admin/support

我不知道如何像我想要的那样更改配置。

I want to configure Kohana 2.x to have links in this format:

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:

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

I don't know how to change the configuration like I want to.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尐籹人 2024-10-27 04:45:10

在 htaccess:: 中写入以下代码,

RewriteEngine On

RewriteBase /

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

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

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

也可以将 config.php 文件更改为:

$config['index_page'] = '';

另一种尝试

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

尝试更多解决方案,然后查看
如何正确设置Kohana的.htaccess,使URL中没有难看的“index.php/”?
另请参阅以下内容::
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-网址

Write following code in 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['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?
see also following tuts::
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文