Home > Mobile >  Keep original URL after redirection by domain provider
Keep original URL after redirection by domain provider

Time:10-16

Goal

fharrell.com/* is redirected by the domain provider to hbiostat.org/blog/*. I want to keep the address bar showing fharrell.com/*

Apache2 Setup

  • /etc/apache2/apache2.conf is standard with the following exception:
<Directory /home/ubuntu/htdocs/>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
  • /etc/apache2/sites-enabled/hbiostat.org.conf is symbolically linked from /etc/apache2/sites-available/hbiostat.org.conf
  • hbiostat.org.conf sets the document root as /home/ubuntu/htdocs which has been working well for some time
  • Contents of hbiostat.org.conf:
<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot /home/ubuntu/htdocs
    ServerName  hbiostat.org
    ServerAlias www.hbiostat.org
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

<Directory /home/ubuntu/htdocs>
  Options FollowSymLinks
  AllowOverride None
  Require all granted
</Directory>

<Directory /home/ubuntu/htdocs/blog>
RewriteEngine on
RewriteBase /
RewriteRule ^hbiostat\.org/blog$ fharrell.com [R]
</Directory>
       Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/hbiostat.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/hbiostat.org/privkey.pem
</VirtualHost>

<VirtualHost *:80>
ServerName hbiostat.org
ServerAlias www.hbiostat.org
DocumentRoot /home/ubuntu/htdocs
<Directory /home/ubuntu/htdocs/blog>
RewriteEngine on
RewriteBase /
RewriteRule ^hbiostat\.org/blog$ fharrell.com [R]
</Directory>
</VirtualHost>

Systax was checked using sudo apachectl -t. I checked that mod rewrite is active using sudo a2enmod rewrite and restarted the server with sudo systemctl restart apache2

But this has no effect, with hbiostat.org/blog/* remaining in the addressbar.

Tried: Many remedies on stackoverflow.com (including the two below) and elsewhere, including putting the commands into an .htaccess file (I'd like to avoid the .htaccess approach).

Any help appreciated.


Redirect domain but keep original url

Redirect subfolder URL but keep original domain name

CodePudding user response:

You can't make the browser display a different domain after a 30x redirect.

mod_rewrite doesn't do what you're thinking it does.

  • Related