Reputation: 47
When I put "?" after slash to make it optional, like this:
RewriteRule ^user/(.*)/?$ "/index.php?page=view-user&user=$1"
But now when I open URL with slash like /user/revolution/ in PHP, $_GET['user'] output "rloveution/" (with slash). So how can I make the trailing slash optional without getting username output with slash ?
Thanks.
Upvotes: 2
Views: 109
Reputation: 785631
You can use negated regex:
RewriteRule ^user/([^/]+)/?$ index.php?page=view-user&user=$1 [L,QSA]
Or lazy matching:
RewriteRule ^user/(.+?)/?$ index.php?page=view-user&user=$1 [L,QSA]
Upvotes: 1