Header menu

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

Thursday, 15 May 2014

Use of RedirectMatch 301 directive in htaccess.


 

Use of  RedirectMatch 301 directive in htaccess.

To redirect more than a single page using htaccess, you can use the "RedirectMatch 301" directive, which allows you to specify directory matching patterns using regular expressions.

Here  301 redirect is a permanent redirect method which passes between 90-99% of  ranking power to the new redirected page and (?i) signifies case insensitivity .

Point to remember:

1. (?i) starts case-insensitive mode
    (?-i) turns off case-insensitive mode

2.  /directory/cart   This is the directory which i am redirecting . When this directory structure will occur in url , page will be redirected to stated page.

3.   http://localhost/directory2?   This is my new address where i want page to be redirected.

Thursday, 12 September 2013

Using some other file as index file when no index file is in the directory using .htaccess

Alternative index file using .htaccess

When there is no index file in php directory and you want that some other file act as index file then this code can be helpful
search is done from left to right ... whichever file is found first will be shown as index file


DirectoryIndex index.php index1.php index2.php index3.php

# u can use any name you want in place of index1.php

Commenting in the .htaccess file

Commenting in the .htaccess file

#Commenting in the .htaccess file is done by adding a # at the beginning of the line that you wish to comment.
#This instructs the server to ignore that line in the .htaccess file.

Hide directory information in php when index file is not present using .htaccess.

When no index file is present in directory and you want to hide listing on other files in php then .htaccess can be used to hide directory information.
Just copy the below lines in .htaccess file and put .htaccess file in directory for which you want to hide files list.

Options -Indexes

Tuesday, 3 September 2013

How to block an ip address from visiting your website using .htaccess ?

1. Make a .htaccess file and save it in your root directory.
2. copy the code below:

order allow,deny
deny from 255.0.0.0   (blocked address)
deny from 192.168.1.96  (blocked address)
allow from all




3.  Paste in file and change the ip address to which you want to block.

4.  save the file