gpt4 book ai didi

apache - .htaccess 重定向到目录中的文件

转载 作者:可可西里 更新时间:2023-11-01 15:30:03 34 4
gpt4 key购买 nike

网站将很快停止维护。与此同时,所有访问者都将被重定向到一个页面,该页面指示该网站将在短时间内关闭,直到维护完成。

如果我想将所有与我的 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/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com