douxiapi4381 2014-04-13 17:46
浏览 46
已采纳

如何在.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>
  • 写回答

1条回答 默认 最新

  • duaijiao0648 2014-04-13 17:53
    关注

    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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?