: How to redirect if directory does not exist or should not be seen? I am using Apache and want to modify my .conf file for a website such that: If the request comes from my IP 1.2.3.4,
I am using Apache and want to modify my .conf file for a website such that:
If the request comes from my IP 1.2.3.4, just display the URL/page as requested
If the request is not from my IP and the directory does not exist, redirect to root
If the request is not from my IP and the directory is one I don't want to display to anyone (example.com/secret/, example.com/secret2/hidden.html, etc.), redirect to root
What is the best way to do this?
More posts by @Shakeerah822
1 Comments
Sorted by latest first Latest Oldest Best
Best way to do this is not from your .conf file.
Do this:
.htaccess example:
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !^192.168.1.1 #Replace with IP address you wish to allow
RewriteRule .* www.yourwebsite.com [R=301,L] #Replace webaddress with yours
Make this file in the directories you are trying to keep people out of.
Then make a custom 404 page that redirects to root for the non-existant directories.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.