php - RedirectRule with conditions in htaccess -


so far have learnt rewriterule ^([^/]*)/$ index.php?page=$1

problem 1: how parse url parameters after point point?

e.g. want page http://example.com/index.php?page=x&id=2&err=10 appear http://example.com/x/?id=2&err=10. given parameters id or err not exists. may or may not present others.

problem 2: specific pages suppose page=a or page=b, if id exists, there third parameter well.

e.g. want page http://example.com/index.php?page=a&id=10&name=abe appear http://example.com/a/abe/10/ , http://example.com/index.php?page=a&id=10&name=abe&err=101 appear http://example.com/a/abe/10/?err=101

edit 30 jan, 16

ok. after searching found implemented using {query_string}. when place rewriterule ^([^/]*)$ index.php?page=$1&%{query_string} [nc,l] in htaccess ajax goes haywire. want working implement index.php , no other pages.

url rewrite parameters

using rewritecond rule able solve problem 1, however, yet implement problem 2.

rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^([^/]*)$ index.php?page=$1&%{query_string} [nc,l] 

solved problem 2 well:

rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^a/([^/]*)/([^/]*)/$ index.php?page=a&id=$1&z=$2&%{query_string} [nc,l]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^b/([^/]*)/([^/]*)/$ index.php?page=b&id=$1&z=$2&%{query_string} [nc,l] 

note: reason using (below) lines caused mess. removing comment them works fine.

rewritecond %{request_filename} !-d # not dir rewritecond %{request_filename} !-f # not file rewriterule ^(.*)$ index.php?page=$1&%{query_string} [nc,l] 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -