且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

重写规则htaccess的文件是否存在

更新时间:2023-11-28 09:53:52

您不能用于 -f 测试的相对位置。你需要包括完整路径:

You can't use a relative location for the -f test. You'll need to include the full path:

RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/folder/offline.txt -f
RewriteCond %{REQUEST_URI} !/websiteOffline.php
RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$
RewriteRule  ^(.*)  /websiteOffline.php [L]

其中, /文件夹/ 是你的htaccess文件是在路径中。

where /folder/ is the path that your htaccess file is in.

在这里,如果你的IP地址是 12.34.56.78 ,并尝试访问该文件夹,也不会重定向你。

Here, if your IP address is 12.34.56.78 and you try accessing the folder, it won't redirect you.