Web Dev, Linux, WordPress & More

Archive for the ‘Linux’ Category

Prevent File Browsing with .htaccess

by eric on January 21st, 2007 in: LinuxOther StuffWeb Design

Need to block access to a directory on your site?

If your hosting environment runs the Apache web server, you can simply create an .htaccess file in the directory you’d like to protect and insert the following code:

Options -Indexes

For example, say you’ve created a sub-folder on your site to hold images. Without protection, a user could visit http://yoursite.com/images/ and see a directory listing of the files and folders in the images directory.

By simply creating a file with the above line and saving it as .htaccess in the images directory, users will get an error rather than a directory listing when they visit the URL.

For more info on .htaccess, visit the Apache website.

technorati tags:,

Create custom error pages using .htaccess

by eric on January 19th, 2007 in: LinuxWeb Design

If you’re running a site on Apache’s web server, you can easily create custom error pages using Apache’s .htaccess file.

First, create or edit an .htaccess file in your public_html directory so that it has the following lines in it:

ErrorDocument 404 /myerrors/404.html
ErrorDocument 403 /myerrors/403.html
ErrorDocument 500 /myerrors/500.html

Here’s what each piece does:

Read more…