【问题标题】:Keep original URL after redirection by domain provider域名提供商重定向后保留原始 URL
【发布时间】:2022-10-13 21:25:06
【问题描述】:

目标

fharrell.com/* 被域名提供商重定向到hbiostat.org/blog/*。我想保持地址栏显示fharrell.com/*

Apache2 设置

  • /etc/apache2/apache2.conf 是标准的,但有以下例外:
<Directory /home/ubuntu/htdocs/>
        Options FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>
  • /etc/apache2/sites-enabled/hbiostat.org.conf/etc/apache2/sites-available/hbiostat.org.conf 符号链接
  • hbiostat.org.conf 将文档根设置为 /home/ubuntu/htdocs 已经运行了一段时间
  • hbiostat.org.conf的内容:
<VirtualHost *:443>
    ServerAdmin my@email.address
    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>

使用sudo apachectl -t 检查系统税。 我使用 sudo a2enmod rewrite 检查了 mod rewrite 是否处于活动状态,并使用 sudo systemctl restart apache2 重新启动了服务器

但这没有任何效果,hbiostat.org/blog/* 仍保留在地址栏中。

试过: stackoverflow.com(包括下面的两个)和其他地方的许多补救措施,包括将命令放入.htaccess 文件(我想避免.htaccess 方法)。

任何帮助表示赞赏。


Redirect domain but keep original url

Redirect subfolder URL but keep original domain name

【问题讨论】:

    标签: apache apache2


    【解决方案1】:

    您无法在 30 倍重定向后让浏览器显示不同的域。

    mod_rewrite 不会按照您的想法去做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-06
      • 2015-07-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 2020-08-25
      相关资源
      最近更新 更多