.htaccess 重定向_如何使用htaccess重定向将旧域重定向到新域

.htaccess 重定向

I want to move the sub domain blog.pkill.info to systutorials.com permanently. I can manage all the pages I want to post using WordPress. Changing domain in a bad way is dangerous. Put a page the tell the reader that the site is moved to a new domain is very unfriendly to the user and also the search engine. When I moving my blog two my own domain from HKUST’s iblog, I found most of the readers don’t try to search and find the pages that interest them in the new domain especially when they find the old site by a search engine.

我想移动子域博客。 将pkill .info永久访问systutorials.com。 我可以使用WordPress管理要发布的所有页面。 以错误的方式更改域很危险。 在页面上告诉读者该站点已移至新域对用户和搜索引擎都非常不友好。 当我从HKUST的iblog中将博客移到我自己的域中时,我发现大多数读者都不会尝试在新域中搜索和查找感兴趣的页面,尤其是当他们通过搜索引擎找到旧站点时。

301 Redirect

301重定向

301 redirect is the most Reader Friendly and Search Engine Friendly method for webpage redirection. The user can get the same page even if they use the old URL. The browser will automatically redirect them to the new address of this page. Of course the URL structure except the domain should keep the same. And the 303 redirect method should preserve the search engine rankings for that particular page. The code “301” is interpreted as “moved permanently”.

301重定向是网页重定向中对读者和搜索引擎最友好的方法。 即使使用旧的URL,用户也可以获得相同的页面。 浏览器将自动将它们重定向到此页面的新地址。 当然,除域之外的URL结构应保持相同。 303重定向方法应保留该特定页面的搜索引擎排名。 代码“ 301”被解释为“永久移动”。

.htaccess redirect

.htaccess重定向

The .htaccess method of redirection only works when the server is Apache and the Apache Mod-Rewite module is enabled.

重定向.htaccess的方法仅在服务器为Apache且启用了Apache Mod-Rewite模块时才有效。

Create a .htaccess file in the root directory of the old domain (blog.pkill.info in this example). Then add the below code the .htaccess file:

在旧域的根目录(此示例中为blog.pkill.info)中创建一个.htaccess文件。 然后将以下代码添加到.htaccess文件中:

# BEGIN Redirect
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://www.systutorials.com/$1 [R=301,L]
</IfModule>

# END Redirect

With the above code, it will be ensured that all the directories and pages of the old domain (blog.pkill.info) will get correctly redirected to the new domain. The domain part can be changed to any domain that is needed.

使用上面的代码,可以确保将旧域(blog.pkill.info)的所有目录和页面正确地重定向到新域。 域部分可以更改为所需的任何域。

For WordPress, changing the application files is not enough. The domain name has also been stored in the database so the site owner should also change the entries that store the domain name in the database using some tools like phpMyAdmin. There are two entries should be changed in the table wp_options. Just find the two entries whose value is the old domain and change it to the new domain. Then the new domain will be in service now ;)

对于WordPress,仅更改应用程序文件是不够的。 域名也已存储在数据库中,因此站点所有者还应使用诸如phpMyAdmin之类的工具来更改将域名存储在数据库中的条目。 表wp_options中应更改两个条目。 只需找到两个值为旧域的条目,然后将其更改为新域即可。 然后,新域将立即投入使用;)

翻译自: https://www.systutorials.com/how-to-redirect-old-domain-to-new-domain-using-htaccess-redirect/

.htaccess 重定向

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值