Mypack H
Mypack H

Reputation: 35

Not Equal Condition for RewriteRule on .htaccess file

How to apply NOT EQUAL condition in inside RewriteRule statement. For example, I want to call mypage.php file and pass an argument only when user not typed "test" data as a parameter. Other than "test" data system should call mypage.php by passing the given argument.

RewriteRule ^/?mypage/!(test)$ mypage.php?arg=$1 [L,NC]

Upvotes: 1

Views: 1334

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

You can use it like this :

RewriteRule ^/?mypage/((?!test).*)$ mypage.php?arg=$1 [L,NC]

((?!test).*) means Any characters zero or more times excluding test .

Upvotes: 3

Related Questions