user2580203
user2580203

Reputation: 33

htaccess exclude file from rewrite rule

Trying to exclude a single file from a rewrite rule that otherwise forces all requests to https. The rule itself works, but I cannot seem to find the correct syntax for the exception.

I am trying to exclude GET requests that look like:

http://savepostage.com/cgi-bin/version.pl or the same with ?[somestring] appended

Here's what I am using:

RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI}!.\version.pl
RewriteRule ^(.)$ https://savepostage.com/$1 [R,L]

It forces all requests to https, regardless of whether I include or delete the second line.

I must be missing some syntax here.

Thanks for any help.

Upvotes: 1

Views: 394

Answers (1)

Pavneet_Singh
Pavneet_Singh

Reputation: 37414

Try this '/' for a sub-directory

RewriteCond %{REQUEST_URI} !^/version\.pl$ 

The rule will be skipped if file is version.pl where '^' matches the exact 'version' file name

Upvotes: 1

Related Questions