apache - mod_rewrite writing local routes -
you see, want redirect [r] http://www.domain.com/dir1/ http://www.domain.com/.
i want accept http://www.domain.com/dir1/([0-9]+) , [l] requests dir1.php?query=$1. , [l] http://www.domain.com/dir1/(.+) root.
so these rules:
rewriterule dir1/([0-9]+) dir1.php?query=$1 [l] rewriterule dir1/(.+) $1 [l] rewriterule dir1/ . [r,l]
the problem last 1 (and tried many variations of it) redirects http://www.domain.com/home/domain/www/. mean, inserts local directory. want redirect http://www.domain.com/
thanks,
use path slash redirect client absolute path.
rewriterule dir1/ / [r,l]
the mistake using .
instead of /
.
this comes straight rewriterule examples:
inside per-directory configuration /somepath (/physical/path/to/somepath/.htacccess, rewritebase /somepath) request ``get /somepath/localpath/pathinfo'': given rule resulting substitution ---------------------------------------------- ---------------------------------- [... snip ...] ^localpath(.*) /otherpath$1 /otherpath/pathinfo
in our case /otherpath
/
, don't use $1
since don't want local part.
you can redirect using absolute urls. useful redirecting http requests https or going other websites. can redirect same server this:
rewriterule dir1/ http://%{http_host}/ [r,l]
but needlessly complicated.
Comments
Post a Comment