网站将很快停止维护。与此同时,所有访问者都将被重定向到一个页面,该页面指示该网站将在短时间内关闭,直到维护完成。
如果我想将所有与我的 IP 不匹配的流量重定向到位于 maintenance
目录中的此页面
https://example.com/maintenance/index.php
这些重写规则是否有效和/或对我想要完成的工作有效?
RewriteCond %{REQUEST_URI} !/maintenance/index.php$
RewriteCond %{REMOTE_ADDR} !^192\.192\.192\.192$
RewriteRule $ /maintenance/index.php [R=302,L]
最佳答案
在 .htaccess 中执行此操作
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ /maintenance/index.php [L,QSA]
任何访问您网站上某些链接的人都将被重定向到:
www.yourwebsite.extension/maintenance/index.php
关于apache - .htaccess 重定向到目录中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53918239/