首页 文章

.htaccess - 检测/放大/结束URL并将规则重写为html文件

提问于
浏览
0

请帮助在.htaccess文件中实现以下功能

请求网址

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

要检查的必要条件

  • 检查URL末尾是否/ amp /出现[AND]

  • 检查/mobile/folder/file.html文件是否存在

重写规则

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

1 回答

  • 1

    希望以下内容有所帮助:

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

相关问题