Htaccess redirects only if it has a value after the forward slash

I would like to apply the following htaccess rule only if after the forward slash /events/

If I visit /events/

(do nothing. DO NOT enforce htaccess rule)

But if I find myself /events/this-can be-anything/

(apply the htaccess rule below)

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

      

This obviously doesn't work.

+3


source to share


1 answer


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



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

      

+1


source







All Articles