Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.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 - Fatal编程技术网

.htaccess 在我的案例中,如何重写htaccess条件

.htaccess 在我的案例中,如何重写htaccess条件,.htaccess,.htaccess,我在.htaccess中有一个重写语句,如下所示。 有没有可能减少行数或语句数 RewriteEngine On RewriteCond %{REQUEST_URI} /file1.asp RewriteRule ^.*$ /project/test.php?file=1 [R=302] RewriteCond %{REQUEST_URI} /customer.form RewriteRule ^.*$ /project/test.php?form=true [R=302] RewriteCon

我在.htaccess中有一个重写语句,如下所示。 有没有可能减少行数或语句数

RewriteEngine On
RewriteCond %{REQUEST_URI} /file1.asp
RewriteRule ^.*$ /project/test.php?file=1 [R=302]
RewriteCond %{REQUEST_URI} /customer.form
RewriteRule ^.*$ /project/test.php?form=true [R=302]
RewriteCond %{REQUEST_URI} /clear
RewriteRule ^.*$ /project/test.php?clear=1 [R=302]
RewriteCond %{REQUEST_URI} /redirect
RewriteRule ^.*$ /project/test.php?url=play [R=302
]


我觉得上面的陈述可以减少。可能吗?非常感谢

是的,您可以使用regex替换使用这样一个规则:

RewriteEngine On

RewriteRule (file1\.asp|customer\.form|clear|redirect) /project/test.php [R=302,L,NC]

这将取代您的所有4条规则。

非常感谢@anubhava请查看我的更新问题。在本例中,如何将基于url的查询字符串传递到test.php+请不要这样做。你最近的编辑完全改变了问题的性质。现在单个规则不起作用,只需删除
RewriteCond%{REQUEST\u URI}
。所以我假设我们在这里做不了什么?正如我上面所示,对于每个规则,只能删除
RewriteCond%{REQUEST_URI}