lvil
lvil

Reputation: 4326

Hyphen in regular expression in htaccess

There is this regexp in htaccess:

RewriteRule ^collection/([^/_]+)games/$ some.php?coll=$1 [L]  

It works fine for url's like "/collection/somegames/"
But i want the rule to accept these url's: "/collection/some-games/" to be redirected to "some.php?coll=some" I change it to:

RewriteRule ^collection/([^/_]+)-games/$ some.php?coll=$1 [L]   

or

RewriteRule ^collection/([^/_\-]+)-games/$ some.php?coll=$1 [L] 

None of the above helped.
What is the solution?

Upvotes: 1

Views: 492

Answers (1)

lanzz
lanzz

Reputation: 43158

RewriteRule ^collection/([^/_]+?)-?games/$ some.php?coll=$1 [L]

There you go.

Upvotes: 2

Related Questions