Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess 带参数和不带参数的htaccess重定向_.htaccess_Mod Rewrite_Url Rewriting_Url Redirection - Fatal编程技术网

.htaccess 带参数和不带参数的htaccess重定向

.htaccess 带参数和不带参数的htaccess重定向,.htaccess,mod-rewrite,url-rewriting,url-redirection,.htaccess,Mod Rewrite,Url Rewriting,Url Redirection,我正在尝试执行以下重定向: 如果用户来自:www.example.com/folder/sub-folder/,它将被重定向到www.example.com/filehtml.html 这工作正常 如果用户来自:www.example.com/folder/sub-folder/index.html,它将被重定向到www.example.com/filehtml.html 这是行不通的 如果用户来自:www.example.com/folder/sub folder/?id=1&id2=2,它将

我正在尝试执行以下重定向:

如果用户来自:www.example.com/folder/sub-folder/,它将被重定向到www.example.com/filehtml.html

这工作正常

如果用户来自:www.example.com/folder/sub-folder/index.html,它将被重定向到www.example.com/filehtml.html

这是行不通的

如果用户来自:www.example.com/folder/sub folder/?id=1&id2=2,它将被重定向到www.example.com/filehtml.html?id=1&id2=2

这工作正常

如果用户来自:www.example.com/folder/sub folder/index.html?id=1&id2=2,它将被重定向到www.example.com/filehtml.html?id=1&id2=2

这是行不通的


我做错了什么?

用以下规则替换所有代码:

RewriteEngine On

RewriteRule ^folder/sub-folder/ /filehtml.html [L,NC,R=302]
查询字符串将自动转入/filehtml.html

确保将其放置在root.htaccess中 确保这是第一条规则
不起作用。我的htaccess上有很多规则,其中一些规则需要类似于本例。正如我所建议的,这需要作为第一个规则放置,并且必须位于root.htaccess中。您在/folder/或/folder/sub folder/中也有.htaccess权限吗?
RewriteEngine On

RewriteRule ^folder/sub-folder/ /filehtml.html [L,NC,R=302]