I want to use htaccess to check if a file called offline.txt exists in the same directory as the htaccess file, if it exists then do:
RewriteRule ^.*$ /websi
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]
where /folder/
is the path that your htaccess file is in.
Here, if your IP address is 12.34.56.78
and you try accessing the folder, it won't redirect you.