Right now my .htaccess
looks like this:
If that is all you have in your .htaccess
file then you can include some exceptions for the URLs you want to exclude before your existing rule that redirects.
For example:
# Prevent further processing if requesting a URL of the form
# example.com/tt.php?xxx (where xxx can be any number)
RewriteCond %{QUERY_STRING} ^\d+$
RewriteRule ^tt\.php$ - [L]
# Prevent further processing if requesting a URL of the form
# example.com/top/xxx/site/xxx (where xxx can be any number or characters)
RewriteRule ^top/[^/]+/site/ - [L]
By placing the above "exceptions" first then any directives that follow (ie. the redirect) will be skipped.
UPDATE: If you had other directives in your .htaccess
file that should still apply to these URLs then you can instead add additional conditions to your existing redirect rule instead.
For example:
RewriteCond %{THE_REQUEST} !^[A-Z]{3,6}\s/tt\.php\?\d+\sHTTP
RewriteCond %{REQUEST_URI} !^/top/[^/]+/site/
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
Note that the first two conditions have a !
prefix on the CondPattern in order to negate its meaning. So, the condition is only successful if the regex does not match.
Note that instead of using two directives (RewriteCond
and RewriteRule
) as I did in the first example to match against the URL /tt.php?xxx
I combined this into a single rule and matched against THE_REQUEST
- this is to simplify the logic in this one rule.
THE_REQUEST
server variable holds the first line of the HTTP request.