Mobile app version of vmapp.org
Login or Join
Hamaas447

: How to set up a 403 forbidden I've recently set up my first commercial website for someone, with godaddy hosting. I want to set up a 403 forbidden on several directories (and their contents)

@Hamaas447

Posted in: #403Forbidden #Godaddy #Htaccess #Php

I've recently set up my first commercial website for someone, with godaddy hosting.

I want to set up a 403 forbidden on several directories (and their contents) that are referenced to through php only (e.g. /includes, /txt).

How can I set this up firstly so it's forbidden, and secondly, so it redirects to a custom page?

Also on godaddy I can't seem to get to the root of my server, it simply takes me to the 'html' folder, but I believe the .htaccess file is located at a higher-level directory. How can I access this?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Hamaas447

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kevin317

Create an .htaccess file in the directory you wish to block, or your root HTML directory if you want this to affect your entire website. Place this code inside:

# Block includes if they have a .inc.php extension. Change
# that to match whatever extension you use for your includes.
<Files *.inc.php>
Order Deny,Allow
Deny from All
</Files>

# Block access to .txt files
<Files *.txt>
Order Deny,Allow
Deny from All
</Files>

# Create a custom page for all 403 errors
ErrorDocument 403 /misc/403.php

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme