Example 4: Force www prefix
Forcing your web site to always be accessible at www.yourdomain.com instead of yourdomain.com can be accomplished with mod_rewrite as well.
2 | RewriteCond %{HTTP_HOST} ^yourdomain.com |
IP Restrictions
If you wish to limit who may visit a specific directory of your web site, placing a .htaccess file with the following code will either allow or deny them. This feature is used when you wish to secure an area of your web site based on the IP address of the visitor. If someone who has been denied access visits this page, they will receive a 403 error code response page which you may customize using the ErrorDocument directive.
Example 1: Allow only 1 IP
This will only allow a visitor with the IP address of 127.0.0.1.
Example 2: Disallow 1 IP
This will only disallow a visitor with the IP address of 127.0.0.1.
Example 3: Allow multiple IPs
This will only allow a visitor who’s IP address is either 192.168.0.1 or 192.168.0.2. You may add as many IPs as you wish, adding each one on a new line.
Example 4: Allow IP range
This will only allow a visitor with an IP that begins with 192.168.0.* where * is any number between 0 and 255.
Directory Browsing
When you wish to display the contents of a directory similar to Windows Explorer or Mac’s Finder application, you should enable the option of Directory Browsing. This will display a list of files in the directory that you place the .htaccess containing this code.
Example 1: Enable directory browsing
1 | Options +Indexes +MultiViews |
Example 2: Hide file types
This will enable directory browsing but will hide all .php and .html files.
1 | Options +Indexes +MultiViews |
2 | IndexIgnore *.php *.html |
Password Protected Directories
While Netfirms provides a method of password protecting directories via the Netfirms Control Panel, you may run out of available slots. If this happens, you must manually password protect your directories using a .htaccess file. There are two steps to creating a password protected directory or folder that you must complete. First is the creation of the .htaccess file as well as the creation of the .htpasswd file.
No comments:
Post a Comment