Showing posts with label htaccess. Show all posts
Showing posts with label htaccess. Show all posts

Thursday 9 October 2014

How to change the default directory index page using an .htaccess file?

You can use the DirectoryIndex directive in an .htaccess file 
to specify a custom file or files that the web server looks for 
when a visitor requests a directory. To enable the DirectoryIndex 
directive, use a text editor to modify the .htaccess file as 
follows. Replace filename with the file that you want to 
display whenever a user requests the directory:

DirectoryIndex filename

You can also specify multiple filenames, and the web server
 will search for each file until it finds a match. Consider 
this example directive:

DirectoryIndex index.php index.html index.htm

How to enable and disable directory index listings using an .htaccess file?

Enable directory index listings
In some cases, however, you may want to enable index listings for a directory. 
To do this, use a text editor to add the following line to the .htaccess file:

Options +Indexes

This directive enables standard indexing, where the index listing shows 
only the filenames. You can also enable “fancy” indexing, where the 
index listing shows filenames, their filesizes, and when they were 
last modified. To do this, add the following line to the .htaccess file:

IndexOptions +FancyIndexing

How to protect your file content using htaccess?

# Prevent Apache from serving .htaccess files:
<FilesMatch "^\.htaccess">
    Order allow,deny
    Deny from all
</FilesMatch>

Sunday 17 August 2014

Disable Hotlinking Images from Searchengines with htaccess

The following code is used to prevent HotLinking to jpg, jpeg, gif, png, and bmp file types.

RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://(www.)?your-websitename.com/.*$ [NC]
RewriteRule .(jpg|jpeg|gif|png|bmp)$ - [F]

Thursday 10 April 2014

Basic Htaccess Redirect


Basic Htaccess Redirection

RewriteCond %{REQUEST_URI} ^/dir/admin/index.php$
RewriteRule ^admin/index.php$  /dir/views/admin/index.php [L]