源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

12种实现301网页重定向方法的代码实例(含Web编程语言和Web服务器)

  • 时间:2022-07-06 10:15 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:12种实现301网页重定向方法的代码实例(含Web编程语言和Web服务器)
为什么需要使用301重定向: [b]1. 保留搜索引擎的排名[/b]: 301 重定向是最有效的方法,不会影响到搜索引擎对页面的排名。 [b]2. 保留访客和流量[/b]: 如果你将页面链接到大量方法可以访问过的地址,如果不是用重定向的话你就会失去这些用户(不解)原文:If you move your popular page to which a lot of visitors have already linked, you may lose them if you don't used redirect method. This provides a great way to provide your visitors with the information they were looking for and prevent you from losing your traffic. 下面是 11 中实现 301 重定向的方法: [b]1. HTML 重定向/Meta 刷新[/b] 将下面 HTML 重定向代码放在网页的 <head> 节点内: <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com"> 上述代码立即将访客重定向到另外一个页面,你可以修改 content 中 的 0 这个值来表示几秒钟后才进行重定向。例如 content="3; url=http://www.oschina.net/" 表示三秒后再重定向。 [b]2. PHP 重定向[/b]
[url=http://www.newdomain.com/] </script> </head>
[b]10. IIS Redirect [/b]在 Internet 服务管理器中右击你想要重定向的文件和文件夹,选择 "a redirection to a URL". 然后输入目标网址,选中 "The exact url entered above" 和 "A permanent redirection for this resource" 然后点击 'Apply' 按钮。 [b]11. 使用 .htaccess 进行重定向[/b] 创建一个 .htaccess 文件(代码如下)用来将访问呢 domain.com 重定向到 www.domain.com 下,该文件必须放置在网站的root目录,也就是首页放置的目录。 注意: .htaccess 方法的重定向只能在 Linux 下使用 Apache 的 mod_rewrite 模块启用的情况下使用。 [b]12.Nginx中的rewrite [/b]
[u]复制代码[/u] 代码如下:
server {     server_name www.1sucai.cn jb51.net;     if ($host = 'jb51.net' ) {         rewrite ^/(.*)$ http://www.1sucai.cn/$1 permanent; }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部