简体   繁体   English

htaccess将所有页面重写到另一个域的同一页面

[英]htaccess rewrite all pages to same page on another domain

So I've been looking but so far can;t find something that I'm looking for exactly. 所以我一直在寻找,但到目前为止都无法找到我正在寻找的东西。 Looked at this article How can I forward ALL pages to the same exact page on a different domain using .htaccess? 看看这篇文章如何使用.htaccess将所有页面转发到不同域上的同一页面? but it seems to only redirect my home page. 但它似乎只重定向我的主页。

Currently, I'm using WordPress and I need to be able to forward all pages to a new domain. 目前,我正在使用WordPress,我需要能够将所有页面转发到新域。 For example, domain1.com/about-us needs to go to domain2.com/about-us. 例如,domain1.com/about-us需要转到domain2.com/about-us。 But I have about 50 pages this needs to work on. 但我需要处理大约50页。 I would like to see if there is a 1-5 line code to use for this to work. 我想看看是否有一个1-5行代码用于此工作。

Thanks! 谢谢!

Try putting this (above any wordpress rules) in the htaccess file in domain1.com 's document root: 尝试将此(在任何wordpress规则之上)放在domain1.com的文档根目录中的htaccess文件中:

RewriteEngine On
RewriteCond %{HTTP_HOST} domain1.com [NC]
RewriteRule ^(.*)$ http://domain2.com/$1 [L,R=301]

If your 2 domains are one different webservers, or don't share a common document root, you can just use mod_alias, adding this to the htaccess file in domain1.com 's document root: 如果您的2个域是一个不同的Web服务器,或者不共享公共文档根,则可以使用mod_alias,将其添加到domain1.com的文档根目录中的htaccess文件中:

Redirect 301 / http://domain2.com/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 .htaccess将所有页面重定向(重写)到新的域主页 - .htaccess redirect (rewrite) all pages to new domain main page htaccess将所有页面重写为相同的规则 - htaccess rewrite all pages to same rule .htaccess 重写规则将所有页面从一个域重定向到另一个域,除了一个特定的 URL? - .htaccess rewrite rule to redirect all pages from one domain to another EXCEPT for one specific URL? htaccess重写规则将一个域中的所有现有文件和目录转到另一个域中的相同文件路径 - htaccess rewrite rule all existing files and directories in one domain go to same filepath in another domain 如何使用.htaccess将所有页面转发到不同域上的同一页面? - How can I forward ALL pages to the same exact page on a different domain using .htaccess? 如何使用.htaccess将所有页面重定向到除主页之外的其他域 - how to redirect all pages to another domain, except home page, using .htaccess .htaccess使用参数将所有页面重定向到同一页面 - .htaccess redirect all pages to the same page with parameter .htaccess重写到同一服务器上的另一个域,而无需更改URL - .htaccess rewrite to another domain on the same server without url change htaccess,将多个页面重写到同一页面,但将原始值保留在某处 - htaccess, rewrite multiple pages to the same page but keep original value somewhere htaccess重写规则将特定域上的特定页面重定向到另一个URL - htaccess rewrite rule to redirect specific page on specific domain to another url
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM