.htaccess htaccess默认查询字符串值
出于某种原因,我的.htaccess htaccess默认查询字符串值,.htaccess,.htaccess,出于某种原因,我的.htaccess正在为\u url键添加默认值 我的.htaccess AddDefaultCharset UTF-8 DirectoryIndex index.php <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$
.htaccess
正在为\u url
键添加默认值
我的.htaccess
AddDefaultCharset UTF-8
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
当我在http://localhost/my-project/test
并转储查询字符串,我得到以下结果
array(1) {
["_url"]=>
string(11) "/index.html"
}
array(1) {
["_url"]=>
string(11) "/test"
}
我猜这与我的.htaccess和/或服务器(apache)配置有关
这个问题有解决办法吗?为什么我没有预期的结果
array(1) {
["_url"]=>
string(11) "/"
}
这个
index.html
是从哪里来的?我如何摆脱它?由于您的DirectoryIndex
指令可能设置为:
DirectoryIndex index.html index.php
当您访问http://localhost/my-project
Apache加载http://localhost/my-project/index.html
由于此指令,您的请求_URI
变为index.html
(在当前目录中)
当运行RewriteRule
时,它只将当前URI作为GET参数传递,因此在\u url
GET参数中获得index.html
您可以像这样调整规则:
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?_url=/$1 [QSA,L]
</IfModule>
DirectoryIndex.php
重新启动发动机
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^(+)$index.php?\u url=/$1[QSA,L]
现在,
http://localhost/my-project
因为它匹配的是+
模式。对不起,我现在添加了完整的.htaccess
代码。我有DirectoryIndex.php
,但它不工作。划破它!它起作用了。我把这个.htaccess
文件放在另一个文件夹下。我必须将DirectoryIndex.php
添加到父目录的.htaccess
文件中,它就可以工作了!谢谢。