Miguel
Miguel

Reputation: 31

htaccess redirect only if it has value after forward slash

I would like to apply the following htaccess rule only if there is a value after the forward slash of /events/

If I visit /events/ (Don't do anything. DO NOT apply the htaccess rule)

But if I visit /events/this-can be-anything/ (Apply the htaccess rule below)

RewriteRule ^events/(.*) /lp/events/index.php [L]

This is obviously not working.

Upvotes: 3

Views: 308

Answers (1)

Amit Verma
Amit Verma

Reputation: 41229

You need to change your regex pattern (.*) to (.+) to match at least one character after the uri.

RewriteRule ^events/(.+)$ /lp/events/index.php [L]

Upvotes: 1

Related Questions