dimanche 29 mars 2015

mod_rewrite GET form to clean URL

I have tried searching but only came up with this link which I can get to work, just not correctly to apply to my current situation.



RewriteCond %{REQUEST_URI} ^/highscores/personal/$
RewriteCond %{QUERY_STRING} ^user1=(.*)$
RewriteRule ^(.*)$ /highscores/personal/%1? [R=301,L,QSA]

RewriteRule ^highscores/personal/(.*)/vs/(.*) personal.php?user1=$1&user2=$2 [L,QSA]
RewriteRule ^highscores/personal/(.*) personal.php?user1=$1 [L,QSA]
RewriteRule ^highscores/skill/(.*) highscores.php?skill=$1 [L,QSA]
RewriteRule ^highscores/(.*) highscores.php?$1 [L,QSA]


As of right now, it will redirect



http://localhost/highscores/personal/?user1=test


to



http://localhost/highscores/personal/test


like it should.


But I have a compare function which submits a GET request like:



http://localhost/highscores/personal/?user1=test&user2=test2


which needs to come out like



http://localhost/highscores/personal/test/vs/test2


but it comes out like



http://localhost/highscores/personal/test&user2=test2


I've tried a few things but deleted them since they didn't work. I tried adapting what I am already using to rewrite the single personal score to fit the situation but it didn't work.


Any help is appreciated. I don't spend much time working with mod_rewrite so my knowledge isn't concrete. If you could explain to me how you solved it, that'd be great.


Aucun commentaire:

Enregistrer un commentaire