Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess rewriting with the [P] proxy flag

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]
like image 855
Sinklar Avatar asked Sep 14 '10 17:09

Sinklar


People also ask

What is PT in rewrite rule?

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]

What is $1 rewrite rule?

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.

What is QSA in htaccess?

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.


1 Answers

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.

like image 101
Tim Stone Avatar answered Sep 19 '22 18:09

Tim Stone