.htaccess rewritebase +索引文件url not oftingting(PHP / Apache)

时间:2015-01-18 15:50:20

标签: php apache .htaccess mod-rewrite

确定,

所以这是我的.htaccess,RewriteBase设置为/abc/public/。 index.php文件位于/public/文件夹中,该文件夹是/abc/的子文件夹。

RewriteEngine On
Options -Indexes
RewriteBase /abc/public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

如果我从脚本中检索$_GET['url']值,则public索引处始终存在值$url[0]。现在,如果重写基数设置为public,为什么/abc/public/被传递给index.php?

它不应该在/public/之后开始传递值吗?所以说我有/abc/public/method/params/,如果输出print_r($url),我应该得到$url[0] = 'method', $url[1] = 'params' ??

似乎无法解决这个问题。

编辑:

Mods,请忽略最后一面旗帜。事实证明这个问题毕竟是相关的。

1 个答案:

答案 0 :(得分:0)

我相信.htaccess没有根据您的RewriteBase值放在正确的目录中。例如,如果您正在使用:

RewriteBase /abc/public/

然后.htaccess的正确位置应为:

%{DOCUMENT_ROOT}/abc/public/