apache - .htaccess rewriterule - double question marks -
if have .htaccess rewriterules this:
rewriterule ^example/(.*)$ example?id=$1 [l] rewriterule ^(.*)$ index.php?q=$1 [l,qsa,nc]
it rewrite index.php?q=example?id=def
i want index.php?q=example&id=def
i can have rewriterules instead:
rewriterule ^example/(.*)$ example&id=$1 [l] rewriterule ^(.*)$ index.php?q=$1 [l,qsa,nc]
it work, doesn't feel right. what's right way of doing this?
sure, may not feel right, believe way can it.
essentially, think way you're going incorrect. @ end of day, if want rewrite example/4
index.php?q=example&id=4
, that's rule should state. passing through second rule not necessary.
as practice, keep simple:
rewriterule ^([^/]+)/(\d+)$ index.php?q=$1&id=$2 [end,qsa,nc] rewriterule ^(.*)$ index.php?q=$1 [l,qsa,nc]
here, we're checking that's not slash in first part , digits in second part, , rewriting index.php
. else goes straight index.php
without id
query parameter.
Comments
Post a Comment