Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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
Apache Mod rewrite/remove slash behind.html_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Apache Mod rewrite/remove slash behind.html

Apache Mod rewrite/remove slash behind.html,apache,.htaccess,mod-rewrite,url-rewriting,Apache,.htaccess,Mod Rewrite,Url Rewriting,我需要一个mod rewrite 301,从url中删除.html后面的斜杠 例如: 好网址: 错误的URL: html后带有/的错误URL应重写(301)为正确URL 我需要一个请求URI来检测html后面的/*,如果是,则重写它 谢谢试试: RedirectMatch 301 ^/(.*)\.html/ /$1.html 或者使用mod_重写: RewriteRule ^(.*)\.html/ /$1.html [L,R=301] 如果您有其他重写规则,请确保重定向的规则在您已有的规则之

我需要一个mod rewrite 301,从url中删除.html后面的斜杠

例如:

好网址: 错误的URL:

html后带有/的错误URL应重写(301)为正确URL

我需要一个请求URI来检测html后面的/*,如果是,则重写它

谢谢

试试:

RedirectMatch 301 ^/(.*)\.html/ /$1.html
或者使用mod_重写:

RewriteRule ^(.*)\.html/ /$1.html [L,R=301]

如果您有其他重写规则,请确保重定向的规则在您已有的规则之前。

非常感谢。这两个建议都非常有效。我该选哪一个?您更喜欢哪一个?@user2057781这没关系,但如果您有其他重写规则,它可能与mod_alias“
RedirectMatch
冲突。否则,这没关系。