首页 文章

htaccess重定向与域屏蔽WordPress网站无法正常工作

提问于
浏览
4

以下.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

1 回答

  • 0

    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');
     ?>
    

相关问题