假设我有以下网址:
https://mywebsite.com/pages.html?limit=24&start=7440&t=3349.html.html.html
https://mywebsite.com/pages.html.html.html?limit=24&start=8136&t=3358
https://mywebsite.com/pages.html.html?limit=24&start=8136&t=3358.html.html.html.html
如何去掉重复的“.html”部分,只留下一个?
这是一个复杂的情况,经过两个小时的努力,我仍然找不到使用正确的正则表达式来使其工作的方法。
这是我尝试过的:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)((.html){2,})(.*)$
RewriteRule ^(.*)$ https://mywebsite.com/%1%4 [QSA,R=302,L]
我使用 302,因为它是一个临时解决方法,直到我找到解决此问题根源的可行解决方案,但我不断遇到重定向循环。
我想只保留一个 .html,删除所有多次出现的 .html。
示例1:
https://mywebsite.com/pages.html?limit=24&start=7440&t=3349.html.html.html
should redirect to:
https://mywebsite.com/pages.html?limit=24&start=7440&t=3349.html
和
https://mywebsite.com/pages.html.html?limit=24&start=8136&t=3358.html.html.html.html
should redirect to:
https://mywebsite.com/pages.html?limit=24&start=8136&t=3358.html
很抱歉提出这个问题,但这对我来说特别棘手,我找不到解决方案。
提前致谢。