exclude a file from htaccess redirection

by Ramshan 2014-07-02 13:25:39

in some cases, you need to exclude a file from being redirected....use "!" in htaccess file to exclude the file as,
RewriteEngine on
RewriteCond %{REQUEST_URI} !/filename.php
RewriteCond %{REQUEST_URI} ^/(.*).php
RewriteRule ^(.*).php /redirectfilename.php?fname=$1 [R]
for eg, if you want to redirect all the php file except index.php, then your redirect code will be,
RewriteEngine on
RewriteCond %{REQUEST_URI} !/index.php
RewriteCond %{REQUEST_URI} ^/(.*).php
RewriteRule ^(.*).php /test.php?fname=$1 [R]
smileysmileysmiley
423
like
0
dislike
0
mail
flag

You must LOGIN to add comments