Lee Firth
Lee Firth

Reputation: 27

How to exclude just one folder from ReWriteRule

This is my current RewriteRule: RewriteRule ^products(/.)$ products.php I would like it to rewrite for products/anything but not for products/shopping-cart I'm not sure how to do this.

Upvotes: 0

Views: 28

Answers (1)

zx81
zx81

Reputation: 41848

Like this:

RewriteRule: RewriteRule ^products(?!/shopping-cart)(/.)$ products.php

(?!/shopping-cart) is a negative lookahead that ensures that what follows is not /shopping-cart

As @anubhava points out, (/.) looks suspicious. What you want is probably either (/?) (to match an optional /) or (/.*) to match the tail end.

Reference

Upvotes: 1

Related Questions