【问题标题】:codeigniter redirects and search engine botscodeigniter 重定向和搜索引擎机器人
【发布时间】:2016-06-12 00:48:25
【问题描述】:

我是 Codeigniter 的新手。事实上,我什至没有工作。我只是受雇为网站做 SEO。我只能访问网站的cpanel,不能访问codeigniter的dashboard(不知道有没有?)

到目前为止,我已经能够弄清楚所有需要我注意的事情。现在唯一的问题是搜索机器人似乎正在重定向。当我尝试作为 Bingbot 获取时,我得到以下信息

HTTP/1.1 301 Moved Permanently
Connection: close
Date: Sun, 12 Jun 2016 00:34:29 GMT
Content-Length: 234
Content-Type: text/html; charset=iso-8859-1
Location: http://www.domain.com/
Server: Apache



<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.domain.com/">here</a>.</p>
</body></html>

我认为这可能是写入 .htaccess 的重定向规则。但我真的不知道要改变什么才能让机器人顺利抓取网站。查看下面的 .htaccess。

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

我需要在 .htaccess 文件中添加什么内容才能让搜索引擎在不再次访问 http 301 的情况下抓取该网站?谢谢

【问题讨论】:

    标签: .htaccess codeigniter redirect search-engine


    【解决方案1】:

    你为什么把这段代码放在 .htaccess 文件中?

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]
    

    【讨论】:

    • 我没有开发这个网站。另一个开发者做到了。我只是被网站所有者要求为搜索引擎优化它。重定向代码的原因是因为站点所在的文件位于子目录中。虽然主 .htaccess 文件重定向到 /public 目录,但上面的代码是 /public 的 .htaccess 文件中的内容。我只是希望我能在修改重定向指令方面获得帮助,以允许搜索引擎在不改变网站内容的情况下进行抓取。
    猜你喜欢
    • 1970-01-01
    • 2010-11-04
    • 2018-07-06
    • 1970-01-01
    • 1970-01-01
    • 2011-03-04
    • 1970-01-01
    • 2011-02-10
    • 1970-01-01
    相关资源
    最近更新 更多