Wednesday, August 31, 2022

[SOLVED] Redirect but keep the domain the same

Issue

I have an owncloud server, and I would like to setup a second short domain, to keep the shared links short.

lets say we've the longdomain.com and short.com Heres is my httpd lines

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot /var/www/dir/public_html
    ServerName short.com
    ServerAlias www.short.com
    RewriteEngine on
    RewriteRule ^/([A-Za-z0-9]{4,12})$ https://www.long.domain.com/public.php?service=shorty_relay&id=$1 [QSA,L]
    ErrorLog /var/www/dir/error.log
</VirtualHost>

With the current lines, short.com redirects to exactly where I need, but I would like this redirect to be on the background and keep the short domain on the user's browser. How can I do this?

Update:

with this in my short domain virtual host I can visit my owncloud using the short domain. For example: short.com/index.php/apps/files/

the long domain is vanished. I think Im one step forward now.

ProxyPass / https://www.long.domain.com
ProxyPassReverse / https://www.long.domain.com

The next step is to use the the regex so I can load only shorty id links.

How can I combine the rewrite regex above with the proxypass. I've tried ProxyPassMatch butI havent figured out how to use it properly Any ideas?


Solution

If you can't make the same content addressable by short.com, short.com can proxy to the long domain by loading mod_proxy, mod_proxy_http, and changing your rewrite flag from R to P.



Answered By - covener
Answer Checked By - Dawn Plyler (WPSolving Volunteer)