Search code examples
linux.htaccessmod-rewriteapache2mod-proxy

Redirect domain but keep original url


I'm trying to use .htaccess with the proxy tag to redirect owncloud.example.com to owncloud.example.com:7777/owncloud but i need the url in the adressbar to remain unchanged.

This is my current htaccess

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^owncloud\.example\.com [NC]
RewriteRule (.*) http://owncloud.example.com:7777/owncloud [P,L]

However with this configuration I get Proxy Error 502 when i try to browse to the web page.

I have mod_rewrite and mod_proxy enabled.


Solution

  • Looks like it needs the rest of the path info. You may also need to configure owncloud so that it thinks it's at http://owncloud.example.com/. Try this:

    RewriteRule .* http://owncloud.example.com:7777/owncloud/$0 [P,L]