I am trying to do an invisible (transparent ?) rewrite via .htaccess and the proxy flag. It works with the [R] flag but not with the [P] flag because it just gives a 500 error. The two domains are on separate servers and the mod_proxy module is enabled. Is my .htaccess correct?
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =one.com
RewriteRule ^(.*)$ http://two.com/$1 [P]
PT|passthrough If, for example, you have an Alias for /icons, and have a RewriteRule pointing there, you should use the [PT] flag to ensure that the Alias is evaluated. Alias "/icons" "/usr/local/apache/icons" RewriteRule "/pics/(.+)\.jpg$" "/icons/$1.gif" [PT]
In your rewrite, the ^ signifies the start of the string, the (. *) says to match anything, and the $ signifies the end of the string. So, basically, it's saying grab everything from the start to the end of the string and assign that value to $1.
QSA means that if there's a query string passed with the original URL, it will be appended to the rewrite (olle? p=1 will be rewritten as index.
If mod_proxy
was compiled as a shared module, it requires that you explicitly load the relevant submodules too. It's possible that on your server mod_proxy_http
is not enabled, which leads to an internal server error when mod_proxy
tries to handle the request passed to it by mod_rewrite
.
mod_proxy
itself is enabled and probably working like you said, since if you don't have it enabled, use of the P
flag will just generate a 404 response. It's hard to know for sure though without the error log, so you may need to find someone with access to it to see what's going on to help you resolve the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With