完全重定向所有网址,只需更改域名 [英] Redirect all urls exactly, just change domain name

查看:61
本文介绍了完全重定向所有网址,只需更改域名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网址大约为1K的网站.该网站正在移至其他域名.否则,URL将完全相同.我想结合htaccess或某种规则,对所有URL进行一次301重定向.它实际上将域名替换为301重定向.

I have a website with roughly 1K URLs. The website is moving to a different domain name. The URLs will be the exact same though, otherwise. I'd like to incorporate an htaccess or some kind of rule that does a 301 redirect for all URLs in one fell swoop. It would essentially replace the domain name as a 301 redirect.

示例: 当前网址:domain.com/blog/post-1.html 重定向到:newdomain.com/blog/post-1.html

Example: Current URL: domain.com/blog/post-1.html Redirect To: newdomain.com/blog/post-1.html

该操作作为301重定向执行.我该怎么做?谢谢,

And that performed as a 301 redirect. How would I do that? Thanks,

推荐答案

将此规则放在domain.comDOCUMENT_ROOT/.htaccess文件中:

Place this rule in your DOCUMENT_ROOT/.htaccess file of domain.com:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)domain\.com$ [NC]
RewriteRule ^ http://newdomain.com%{REQUEST_URI} [L,R=301]

这篇关于完全重定向所有网址,只需更改域名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆