Reputation: 77
With:
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?pet=$1 [NC]
"www.domain.com/cat" works but "www.domain.com/cat/" doesn't (notice slash at the end).
How can I modify this rule to work with AND without the slash? Or do I need two rules?
Upvotes: 0
Views: 96
Reputation: 785611
Just include an optional trailing slash in your regex:
RewriteRule ^([a-zA-Z0-9_-]+)/?$ index.php?pet=$1 [L,QSA]
You can also use:
RewriteRule ^([\w-]+)/?$ index.php?pet=$1 [L,QSA]
Upvotes: 1