这是我的情况。我的应用程序网址显示如下:
example.com/index.php/article/whatever/here
为了从 url 中删除 index.php,我把它放在我的 .htaccess 中并且工作正常:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
现在,我的问题是我有这样的 include 和 admin.php:
example.com/admin.php/manage/whatever/here
而且我不知道如何在不与 index.php 发生冲突的情况下从 url 中删除 admin.php,因为我已经尝试过了,并且显示了 500 Internal Server Error:
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteRule ^(.*)$ /admin.php/$1 [L]
编辑
另一个尝试是这个,什么都没有,因为显示了 404 错误:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*?)/(.*) /$1/$2 [L]
我所有的网址都应该有几个参数:
example.com/this/is/a/large/url/because/is/requiered
编辑2:
我创建了两条规则,每条规则都可以正常工作!!!但两者不能一起工作:
RewriteRule ^admin/(.*)$ /admin.php/$1 [L]
RewriteRule ^(.*)$ /index.php/$1 [L]