Reputation: 46493
On my server, I would like to redirect all traffic accessed via port 80 via:
http://12.34.56.78/blahblah/...
to a Python web-server, listening for example on port 7777...
... and keep all the rest http://12.34.56.78/(anythingelse)/... to /home/www/
with Apache.
When accessing http://12.34.56.78/blahblah/, I get:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Why doesn't it work with the following Apache config ?
<VirtualHost *:80>
ServerName 12.34.56.78
DocumentRoot /home/www/
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName 12.34.56.78
<Directory /blahblah/>
RewriteEngine On
RewriteRule /(.*) localhost:7777/$1 [P,L]
</Directory>
</VirtualHost>
Upvotes: 0
Views: 197
Reputation: 567
The problem is simply that you're using a second virtualhost with mod_rewrite.
The way RewriteRule works is that you specify the path in the URL to match and it rewrites to something else (or proxies in this case).
Additionally, Directory elements are talking about specific real directories on hosts. You don't appear to want your RewriteRules inside a Directory element based on your question.
Also, you should be specifying the URL scheme in your proxied RewriteRule.
Something along these lines should work.
<VirtualHost *:80>
ServerName 12.34.56.78
DocumentRoot /home/www/
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
RewriteEngine On
RewriteRule ^/blahblah(.*)$ http://localhost:7777$1 [P,L]
</VirtualHost>
Upvotes: 1