【发布时间】:2012-04-15 12:03:39
【问题描述】:
我正在使用 php 构建自己的 MVC 应用程序。 index.php 将是前端控制器。 在 index.php 中,我将使用 $_SERVER['QUERY_STRING'] 获取参数,所以我需要我的
.htaccess 文件将 /attr1/attr2/attr3 重定向到 index.php?attr1/attr2/attr3。
($_SERVER['PHP_SELF'] 不能正常工作)
如果我的 htaccess 文件(apache 服务器)是
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ index.php?$1
</IfModule>
query_string 输出 index.php 但是如果我通过 localhost/something/attr1/attr2/attr3 访问 url 并且 .htaccess 是
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(something)\/(.*)$ index.php?$2
</IfModule>
query_string 正在打印 attr1/attr2/attr3
WTF??
【问题讨论】:
标签: php .htaccess url-rewriting