Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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
Apache2合并规则_Apache_Mod Rewrite - Fatal编程技术网

Apache2合并规则

Apache2合并规则,apache,mod-rewrite,Apache,Mod Rewrite,我的.htaccess中有大约一百条重写规则,例如以下规则: RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/$ https://example.com/cars-and-$1 [R=301,L] RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/0[/]{0,1}$ https://example.com/cars-and-$1 [R=301,L] RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/([

我的.htaccess中有大约一百条重写规则,例如以下规则:

RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/$ https://example.com/cars-and-$1 [R=301,L]
RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/0[/]{0,1}$ https://example.com/cars-and-$1 [R=301,L]
RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)/([0-9]+)$ /pathto/search.php?city=$1&page=$2 [L]
RewriteRule ^cars-and-([%a-zA-Z0-9_-]+)$ /pathto/search.php?city=$1&page=0 [L]
我现在想添加对AMP页面的支持。只需在URL中添加一个.amp结尾,就会显示页面的amp版本

我可以创建100条额外的重写规则来覆盖所有以.amp结尾的情况,但我想知道是否有更简单的方法继续


当检测到.amp添加了amp=1参数,然后返回到现有重写,而不删除amp=1参数时,是否有方法添加单个重写规则?

您可以在现有规则的基础上尝试类似的操作:

重写规则。+\.amp$$1?amp=1

然后将QSA标志添加到现有标志中

请注意,您必须避免该新规则上的[L]标志,以便它通过其余规则