.htaccess rewritebase + 索引文件 url 不偏移 (PHP / Apache)
.htaccess rewritebase + index file url not ofsetting (PHP / Apache)
好的,
所以这是我的 .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= [QSA,L]
如果我从我的脚本中检索 $_GET['url']
值,$url[0]
索引处始终有值 public
。现在,如果重写基数设置为 /abc/public/
,为什么 public
被传递给 index.php?
不应该在/public/
之后才开始传值吗?所以说我有/abc/public/method/params/
,如果我输出print_r($url)
,我不应该得到$url[0] = 'method', $url[1] = 'params'
吗??
似乎无法弄清楚这一点。
编辑:
模组,请忽略最后一个标志。原来这个问题毕竟是相关的。
我认为 .htaccess 未根据您的 RewriteBase
值放置在正确的目录中。例如,如果您使用:
RewriteBase /abc/public/
那么 .htaccess 的正确位置应该是:
%{DOCUMENT_ROOT}/abc/public/
好的,
所以这是我的 .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= [QSA,L]
如果我从我的脚本中检索 $_GET['url']
值,$url[0]
索引处始终有值 public
。现在,如果重写基数设置为 /abc/public/
,为什么 public
被传递给 index.php?
不应该在/public/
之后才开始传值吗?所以说我有/abc/public/method/params/
,如果我输出print_r($url)
,我不应该得到$url[0] = 'method', $url[1] = 'params'
吗??
似乎无法弄清楚这一点。
编辑:
模组,请忽略最后一个标志。原来这个问题毕竟是相关的。
我认为 .htaccess 未根据您的 RewriteBase
值放置在正确的目录中。例如,如果您使用:
RewriteBase /abc/public/
那么 .htaccess 的正确位置应该是:
%{DOCUMENT_ROOT}/abc/public/