BB Design
BB Design

Reputation: 705

.htaccess RewriteRule from folder to file, with exceptions

If I have a rule like this:

RewriteRule ^([A-Za-z0-9-]+)$ /$1.asp [QSA]

I can redirect domain.com/test to domain.com/test.asp

But there may be exceptions where I have a folder called test. How can I override my own rule with exceptions in that case?

Upvotes: 1

Views: 29

Answers (1)

anubhava
anubhava

Reputation: 785376

You can use negative lookahead to create exceptions:

RewriteRule ^(?!test/)([a-z0-9-]+)$ /$1.asp [L,NC,QSA]

Now this rule will be skipped for any request URI that starts with /test/

Upvotes: 1

Related Questions