【问题标题】:htaccess redirect with domain masking for Wordpress site not working带有域掩码的 WordPress 站点的 htaccess 重定向不起作用
【发布时间】:2015-06-01 19:55:13
【问题描述】:

以下 .htaccess 配置在 Wordpress 站点上无法使用屏蔽实现域重定向:

DirectoryIndex index.php

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?redir2$ [NC]
RewriteRule ^ http://redir1%{REQUEST_URI} [L,NE,P]

这是redir2 的.htaccess,用于重定向到redir1 并带有屏蔽。目标是让用户输入例如redir2/sub,提供的内容为redir1/sub,但显示的网址为redir2/sub

它在我的本地安装上运行良好。但是在我的共享主机上,它会重定向而不会屏蔽。我认为问题可能出在服务器配置中。

任何想法可能是什么问题?

仅用于记录这里是我在使用屏蔽重定向时遇到索引文件问题时提出的另一个类似问题:htaccess redirect with domain masking not working when requesting root directory

【问题讨论】:

    标签: wordpress .htaccess mod-rewrite url-redirection


    【解决方案1】:

    Wordpress 规范 URL 功能就是为此而设计的。

    虽然此插件不再受到积极支持,但它可能会起作用。

    <?php
    /*
     Plugin Name: Disable Canonical URL Redirects
     Plugin URI: http://www.ImagineThought.com/
     Description: Disables the "Canonical URL Redirect" feature of WordPress (in versions of Wordpress 2.3 and greater). To use this plugin, simply activate it. Then, disable this if you need to re-enable the "Canonical URL Redirect" feature of WordPress.  
     Version: 1.0.11.0228
     Author: Geoffrey Griffith
     Author URI: http://www.ImagineThought.com/
     License: GPL
    */
    
     remove_filter('template_redirect', 'redirect_canonical');
     ?>
    

    【讨论】:

      猜你喜欢
      • 2015-06-01
      • 1970-01-01
      • 2023-03-29
      • 2016-06-26
      • 2014-07-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-11
      相关资源
      最近更新 更多