tags:

views:

22

answers:

2

Hello,

I'm trying to get two parameters with mod-rewrite. I tried to split them with "-" but unfortunately it returns last word as second parameter.

/ders/ilkogretim-matematik
/ders/ilkogretim-fen-ve-teknoloji

should be the URLs, "ilkogretim" will be the first parameter and the rest of it will be the second parameter. (After first "-")

My rules as follows:

RewriteRule ^ders/(.*)-(.*)/?$  /ogretmenler.php?sinif=$1&ders=$2  [QSA,L]

I hope I could explain the problem..

Thanks in advance...

A: 

Your . is only capturing a single character - you need a quantifier on there. I've also made the first group capture any character except -:

ders/([^-]+)-(.*)/?$ /ogretmenler.php?sinif=$1&ders=$2 [QSA,L]
Greg
A: 

The problem is the single dots (.)-(.) will only match a single character. You probably want something like

^/ders/([^-]*)-(.*)/?$

The first group will match zero or more non "-" characters, followed by the single "-" and then the 2nd group will match zero or more of any character (you could restrict this more if desired).

Sean