如何在.htaccess中忽略特定文件以进行重定向

如何在.htaccess中忽略特定文件以进行重定向

问题描述:

My server provides the default redirection from www.test.com to test.com I want to remove the redirection for one specific file 'abc.php' there. How to go about it?

The default redirection provided in the .htaccess file is:

<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>

Like this (for abc.php):

<IfModule mod_rewrite.c>
    RewriteCond %{HTTPS} !=on
    RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    RewriteCond %{REQUEST_URI} !^(.*/)?abc\.php$ [NC]
    RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
</IfModule>