php - How to get an .htaccess rewrite rule with filtering directory and keeping parameters -


this question has answer here:

i'am trying write rewrite rule , change this:

http://domain.de/adserver/js/first/sec/adtech?loc=300&alias=home&misc=1429871690242 

to:

http://domain.de/adserver/js/adtech.php?a=$1&b=$2 

where $_get in adtech.php shout be:

$_get['a']=first | $_get['b']=sec | $_get['loc']=300 | $_get['alias']=home

the .htaccess-file placed in root/adserver/js. tryed without success:

rewriteengine on options +followsymlinks  rewritebase /   rewritecond %{request_uri} /adserver/js/(.*)/(.*)/adtech$  rewriterule (.*)/(.*)/adtech$ /adserver/js/test.php?a=$1&b=$2  

(my code brings $_get['a']=first | $_get['b']=sec new parameters whats given parameters?)

you can use code in /adserver/js/.htaccess:

rewriteengine on options +followsymlinks  rewritebase /adserver/js/   rewriterule ^([^/]+)/([^/]+)/adtech/?$ test.php?a=$1&b=$2 [l,qsa,nc] 

changes are:

  1. add required flags in rewriterule. esp important qsa preserve original query string.
  2. add appropriate rewritebase.
  3. remove redundant rewritecond
  4. use relative path rewriting in rewriterule.

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -