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:
- add required flags in
rewriterule
. esp importantqsa
preserve original query string. - add appropriate
rewritebase
. - remove redundant
rewritecond
- use relative path rewriting in
rewriterule
.
Comments
Post a Comment