Search code examples
.htaccesscodeigniterhttp-redirectsearch-engine

codeigniter redirects and search engine bots


I am new to codeigniter. In fact, I'm not even working on it. I'm just employed to work the SEO for a website. I only have access to the cpanel of the site, not the dashboard of the codeigniter (I wonder if there is one?)

So far I have been able to figure out everything that needs my attention. Only problem now is the search bots seems to be hitting redirects. When I tried to fetch as Bingbot, I get the following

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>

I figured it might be the redirect rules written into the .htaccess. But I really don't know what to change to allow for the bot to smoothly crawl the site. View .htaccess below.

<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>

What do I need to add to the .htaccess file to allow search engines crawl the site without hitting to http 301 again? Thanks


Solution

  • Why did you put this code in .htaccess file?

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