.htaccess use relative paths in errordocument

Status
Not open for further replies.

filenuke

Active Member
118
2013
28
0
I have a folder I want to protect on my server where everything must be denied and redirected to another specific file
for my htaccess file I have
Code:
ErrorDocument 403 /notforyou.php
Deny From All

the problem with this is that it doesnt work with relative paths. If I have /privatedir as my folder I want to ban the internet from, I dont know any way in apache to use relative path and redirect the user to /privatedir/notforyou.php, its only possible to redirect to the /notforyou.php where ius placed in htdocs root

Does anyone know how I can get this to work my way or be able to somehow input the request directory variable. Like apache knows the request directory is /privatedir and I can put "ErrorDocument 403 variable/notforyou.php" in my htaccess instead somehow

I searched everywhere and I still cant find out how
 
3 comments
just make it so your ip is the only one allowed to view the directory via .htaccess and then redirect all others


order deny,allow
deny from all
allow from (your ip)
 
Last edited:
I know how to do this ban ip htaccess bro I already have ip settings in the notforyou.php which allows only my ip because it can be easy modified from database. I need it to be a way where the hacker has no knowledge of this directory at all and give a 404 error not a forbidden one so it looks like theres nothing interesting there. I want it so if I have for example domain.com/filenuke/panel if snooping user tried to access this panel to give a 404 error with the notforyou.php so it looks like there is no panel in a way where I dont have to modificate anything outside of the panel directory.
 
lol put this in your .htaccess and put the link you want to show up as 403 error and your ip and you will be the only one able to access it


ErrorDocument 403 (your link address)
Order deny,allow
Deny from all
Allow from (your ip)
 
Last edited:
Status
Not open for further replies.
Back
Top