1

My .htaccess file contain this:

RewriteRule ^((products)/([a-zA-Z-]+)*)$ index.php?page=products&category=$3&level=1

it works fine for: word-word (one dash), but it fails for two dash: word-word-word, example:

products/electronics-solid (works here)

products/word-word-word (fails here)

How to solve it?

Akam
  • 955
  • 14
  • 17
  • 2
    What does it do when it *fail*s? Do you want to separate the parts in htaccess or in PHP? – Halcyon Sep 14 '15 at 13:29
  • 2
    From my understanding that regex is working perfectly with any amount of dashes, maybe the problem is not in your .htaccess !? – xception Sep 14 '15 at 13:38
  • 2
    Why the double capture groups? Why the extra repetition `*` after word parts? – mario Sep 14 '15 at 13:38
  • @mario: I changed that when it failed, I tried to match multiple occurrence of dashes – Akam Sep 14 '15 at 21:21
  • @xception: it works perfectly for all cases except (word-word-word)! it fails to redirect – Akam Sep 14 '15 at 21:22
  • "It fails" is not a sufficient description. Enable the [RewriteLog and excerpt error/access.log](http://stackoverflow.com/a/31280108). – mario Sep 14 '15 at 21:29
  • @mario: I solved it, I found the issue: (products) not match for those links that has word-word-word then it fails because there is no word of (products) – Akam Sep 14 '15 at 22:13

0 Answers0