检测 URL 末尾的 /amp/ 并将规则重写为 html 文件



请帮助在.htaccess文件中实现以下目标

请求网址

htpps://www.examplesite.com/folder/file/amp/

要检查的必要条件

  1. 检查网址 [AND] 的末尾是否存在/amp/
  2. 检查/mobile/folder/file.html 文件是否存在

重写规则

重写为 htpps://www.examplesite.com/mobile/folder/file.html

希望以下内容会有所帮助:

RewriteCond %{REQUEST_URI} "^(.+)/amp/$"
RewriteCond "%{DOCUMENT_ROOT}/mobile/$1.html"  -f
RewriteRule "^(.+)/amp/$" "%{DOCUMENT_ROOT}/mobile/$1.html"  [L]

最新更新