regex - htaccess rule delimiters and params for smooth urls -
i'm trying use htaccess rewrite rules create smooth urls. user can call example http://members.clubseat.at/demo/login/?test=123
, code user called http://members.clubseat.at/demo/index.php?page=login&test=123
.
here htaccess code:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]*/)?([^/]*)/?$ ./index.php?p1=$1&p2=$2 [qsa,l]
i want user can leave additional params after page , last slash, .../demo/login/
, .../demo/login
work. if there no last slash (/) login
not in first param in second.
compare: http://members.clubseat.at/demo/login/ vs. http://members.clubseat.at/demo/login
try demo here: http://members.clubseat.at/demo/login/?test=123
but according regex-tester should work: https://regex101.com/r/nk9rm2/2
how can solve problem?
you need use qsa flag append query strings target url.
rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^([^/]*)?/?([^/]*)/?$ ./index.php?p1=$1&p2=$2 [qsa,l]
the third perm automatically appended qsa flag.
Comments
Post a Comment