问题
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.
回答1:
You need to change your regex pattern (.*) to (.+) to match at least one character after the uri.
RewriteRule ^events/(.+)$ /lp/events/index.php [L]
来源:https://stackoverflow.com/questions/44171636/htaccess-redirect-only-if-it-has-value-after-forward-slash