如何从超薄框架URL的index.php [英] How to remove index.php from slim framework URL
问题描述
我想要删除的index.php形成网址:
i'm trying to remove index.php form an URL:
本作品
http://server/bw/index.php/test
这不能正常工作
http://server/bw/test
我试图改变的.htaccess和观看网络上的我看到,它应该是这样的:
i try to change .htaccess and watching on web i see that it should be like this:
RewriteEngine On
RewriteBase /bw/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
我尝试编辑它以这种方式:
i try editing it in this way:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
或以这种方式:
or in this way:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /bw/index.php [QSA,L]
或以这种方式:
or in this way:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-d
但是,当我尝试访问的http://服务器/体重/测试
它说我:
Not Found
The requested URL /bw/test was not found on this server.
Apache/2.2.15 (CentOS) Server at server Port 80
我检查我的的httpd.conf
的LoadModule rewrite_module模块/ mod_rewrite.so
是使..我不要里面知道做什么了吧..
I check that inside my httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
is enable.. i don't know what to do now..
我该如何解决?请大家帮帮我!
how can i solve? please help me!
推荐答案
试试这个,它使用如在Word preSS
Try this, which used e.g. in WordPress
RewriteRule . index.php [L]
或此,它被用来通过例如Lavavel PHP框架
or this, which is used by e.g. Lavavel PHP Framework
RewriteRule ^(.*)$ index.php/$1 [L]
您也可以考虑加入
RewriteCond %{REQUEST_FILENAME} !-d
在该重写规则也排除现有的目录,不仅现有的文件。但是,这取决于你。
before the RewriteRule to also exclude existing directories, not only existing files. But that's up to you.
这篇关于如何从超薄框架URL的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!