我有一个基本的 MVC 结构和一个宁静的 uri 设计:
mysite.com/appdir/:index/:controller/:action/
我想隐藏索引路由参数,所以我的 uri 看起来像:
mysite.com/appdir/:controller/:action/
我的基本文件夹结构是:
appdir/
app/
-->Controller/
-->Model/
-->View/
config/
library/
public/
-->.htaccess
-->index.php
.htaccess
index.php
应用程序目录/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
appdir/public/.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
我似乎无法隐藏索引,我尝试了许多重写规则,但似乎没有任何效果。使用 CodeIgniter,我通常可以添加RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
并解决问题,但是我已经为此工作了 3 个小时,但没有成功。