Opencart

How to remove index.php?route=common/home from URL in OpenCart

In this article We will explain how to remove route=common/home from home page in OpenCart websites. Urls of websites plays very important roles in SEO.

opencart seo url

The index.php?route=common/home appears when you click your home page logo in opencart website.

In this article, we show you how to get rid of that in two ways –

  1. Modify your .htaccess file
  2.  Modify header.tpl
  3. Modify seo_url.php

Method 1

Edit/View the htaccess file and find this line:

RewriteBase /

Below it, paste these three lines:

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://%{HTTP_HOST}? [R=301,L]

Save your htaccess file and your store logo should now be generating the clean URL of your home page.

Method 2

In the header template file (catalog/view/theme/default/template/common/header.tpl)’

Find Below lines in header.tpl file:

<a href=”<?php echo $home; ?>”><img src=”<?php echo $logo; ?>” title=”<?php echo $name; ?>” alt=”<?php echo $name; ?>” class=”img-responsive” /></a>

Replace above code with below code:

<a href=”<?php echo $base; ?>”><img src=”<?php echo $logo; ?>” title=”<?php echo $name; ?>” alt=”<?php echo $name; ?>” class=”img-responsive” /></a>

Hope this article is enough to solve your problem.

Method 3

To simply remove that, you can do a basic replace in /catalog/controller/common/seo_url.php

Find:

return $link;

Before it on a new line put:

$link = str_replace('index.php?route=common/home', '', $link);

Edit by TheBlackBenzKid: If you want full SEO just use this line instead of the above:

$link = str_replace('index.php?route=', '', $link);

Also make sure SEO URLs is turned on in the Admin panel of the store.

 

Leave a Reply

Your email address will not be published. Required fields are marked *