apache - apache2 rewrite rule without changing URL -
this below rewrite redirects localhost
http://www.example.com/?id=211&test=1
want localhost on browser should not changed page come form above link.
i using rewrite rule on apache conf:
rewriteengine on rewritecond %{http_host} ^localhost$ [or] rewriterule ^/?$ http://www.example.com/?id=211&test=1 [l]
this below rewrite redirects localhost
http://www.example.com/?id=211&test=1
want localhost on browser should not changed page come form above link.
if want load page elsewhere without chaining url, mod_rewrite
wrong tool job. utilize mod_proxy
instead. first enable in apache this; illustration assumes on ubuntu 12.04 should work on linux apache install
sudo a2enmod proxy proxy_http
then set enable reverse proxy root path of /
http://www.example.com/?id=211&test=1
:
<ifmodule mod_proxy.c> # proxy specific settings proxyrequests off proxypreservehost on <proxy *> adddefaultcharset off order deny,allow allow </proxy> proxypass / http://www.example.com/?id=211&test=1 proxypassreverse / http://www.example.com/?id=211&test=1 </ifmodule>
edit: seems mod_proxy
, query strings destination not mix; emphasis mine:
this directive allows remote servers mapped space of local server; local server not deed proxy in conventional sense, appears mirror of remote server. local server called reverse proxy or gateway. path name of local virtual path; url partial url remote server and cannot include query string.
so if there anyway set page—maybe on localhost
—that bounce behind scenes. meaning happens on localhost
:
proxypass / bounce.php
and file, bounce.php
have line in it:
<?php header('location: http://www.example.com/?id=211&test=1'); ?>
which allow mod_proxy
have valid destination. , php file redirect? hard say, query string on destination server issue.
apache .htaccess mod-rewrite url-rewriting apache2
No comments:
Post a Comment