【问题标题】:ht access 301 redirect domain.com/news/etc-etc to subdomain/news/etc-etchtaccess 301 将 domain.com/news/etc-etc 重定向到子域/news/etc-etc
【发布时间】:2014-08-08 19:54:26
【问题描述】:

我需要使用 HT 访问将域重定向到子域,但是,由于它是我正在设置的存档站点,我只需要重定向某个子文件夹中的所有 url,而不是主域上的所有内容.

因此,domain.com/news/etc-etc-etc 中的任何帖子/页面/内容都需要重定向到 archive.domain.com/news/etc-etc-etc

这看起来正确吗?

RewriteCond %{HTTP_HOST} ^domain.com\news\$ RewriteCond %{REQUEST_URI} !^archive.domain.com/news/ RewriteRule (.*) archive.domain.com/news/$1

这是一个 wordpress 安装,原因是正在开发一个全新的站点,并且 wordpress 安装正在移动到子域以充当存档,所以我不希望主域上的所有内容.com 重新定向,因为这将是所有新内容的去向。

感谢任何帮助!

【问题讨论】:

  • 这里有什么问题?您能否包含错误消息或说明正在发生/未发生的事情?

标签: wordpress .htaccess mod-rewrite redirect


【解决方案1】:

将此代码放入/news/.htaccess:

RewriteEngine On
RewriteBase /news/

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^ http://archive.domain.com%{REQUEST_URI} [L,NE,R=302]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多