Reputation: 1915
I'm tiring to get all string before first slash when an url ends with "word1" or "word2", and im using this code:
RewriteRule ^(.+)/word1|word2/?$ index.php?query=$1 [NC]
I haven't any problem with url that have "word1" on his ends, but if the url ends with "word2", Apache dose not return any value to "query" variable
Upvotes: 4
Views: 7764
Reputation: 33918
You need to group the alternations in your expression:
^(.+)/(?:word1|word2)/?$
Without the grouping your expression means:
^(.+)/word1
or word2/?$
Upvotes: 5