.htaccess 使用htaccess隐藏地址栏上的维护页

iih3973s  于 2022-11-16  发布在  其他
关注(0)|答案(1)|浏览(111)

如果我想将所有请求重定向到显示“maintenance”的单个页面,我可以在htaccess中执行以下操作

RewriteCond %{REQUEST_URI} !/maintenance.html$ [NC]
RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule .* /maintenance.html [R=307,L]

但如果我想隐藏**/maintenance.html**从网址http://www.example.com/maintenance.html在地址栏我该怎么办?

7vux5j2d

7vux5j2d1#

这是不可能的。
您可以用途:

RewriteCond %{REQUEST_URI} !\.(jpe?g?|png|gif) [NC]
RewriteRule !^maintenance\.html$ /maintenance.html [NC,L]

但在这种情况下,没有错误代码或重定向。
如果你想重定向,地址栏中的url必须有变化。

相关问题