include
include

Reputation: 3

How to ignore a specific file for redirection in .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>

Upvotes: 0

Views: 34

Answers (1)

Paul Denisevich
Paul Denisevich

Reputation: 2414

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>

Upvotes: 1

Related Questions