Index php route common home как убрать
Перейти к содержимому

Index php route common home как убрать

  • автор:

Remove index.php?route=common/home from OpenCart

I currently have User SEO URL’s set to Yes in OpenCart Admin.

System -> Settings -> Store -> Server -> User SEO URL’s

So far, all tags and SEO links are working; the command has done the desired effect.

However for the homepage and a few other links; how do I remove:

From the URL? Do I have to literally do a find and replace in the hardcode PHP files and risk upgrades or is there another way?

(without bloating performance i.e no poor amateur tools such as vQmod)

15 Answers 15

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

Before it on a new line put:

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

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

I really like Victor Schröder’s solution above for it’s simplicity. Thanks! I created a vQmod based on his code mods in case it would be helpful to anyone. here is the code:

But those new buttons though..'s user avatar

The previous «solutions» are wrong because they are attacking the SEO URL translate. What you want is to deal with the URL generation inside OpenCart.

Let’s keep it simple. Go to /system/library/url.php and look at the public function link . Replace the function with this version:

Simple like that. I can’t belive why this is not in OpenCart’s core.

EDIT:

I run some tests and if the SEO URLs are enabled, it becomes necessary to make one single edit in the /catalog/controller/common/seo_url.php to avoid an «Undefined index» error.

Inside public function rewrite , replace this line:

Now it really works.

Step 01. Enable USE SEO URL’s in your store server settings

Go to the “System” and click on “Settings”. Locate the store you want to alter and click the “Edit” link on the right. Finally click the “Server” tab and set the SEO URL’s radio to “Yes” and save your settings.

Note: The keywords will not be created for you automatically. You must also have Apache mod_rewrite turned on. Most web hosts will have this on by default. Step 3 of this tutorial will explain how to add the keywords.

Step 02. Change some content in your .htaccess file to make your homepage SEO URL Friendly

Go to your host control panel and edit your .htaccess file. Sometimes this file is hidden in order to unhide it you can click on your web host control panel file manager and tick the show hidden files option followed by the “go” button.

Once you locate the .htaccess file change the following lines:

If you do the step above your home page will change from something like this: http://yourwebsite.com/index.php?route=common/home to this: http://yourwebsite.com

Step 03. Enter SEO Keywords for URL’s manually Finally, you need to enter SEO keywords for every page, information, product and category you want to have URL rewrite. You can find the field for the SEO Keywords under the Data tab when editing and creating items.

Once you have entered the SEO Keywords your URL’s will be working.

Once you have followed all these instructions you can begin to reap the benefits of higher rankings, increased traffic and more customers.

Удаление «index.php?route=common/home» в Opencart

Удаление «index.php?route=common/home» в Opencart

Эта модификация удаляет « index.php?route=common/home » из URL главной страницы. Дополнение избавит ваш сайт от ссылок на страницу дублирующую главную страницу сайта.

По умолчанию в опенкарт существует дубль главной страницы « yourdomain.com/index.php?route=common/home » после установки все ссылки на главную будут иметь вид « yourdomain.com »

Важно! Работает только с URL-адресами! Для этого в настройках магазина необходимо включить SEO-URL. Не подойдет для SEO PRO.

How to Remove Common/Home in OpenCart 2.3.x and 3.x

So, you’ve enabled your SEO URLs in OpenCart.

Everything is looking fine and you’re happy about the new, shorter URLs.

However, there’s this one, last annoying URL that keeps bugging you.

The index.php?route=common/home appearing after you click your home page logo.

We believe it’s time to solve that once and for all.

In this tutorial, we’ll show you how to get rid of that in two ways — the quick and easy way, as well as the clean and correct way.

Let’s get this over with.

The Problem

This is how the default URL looks like when you’re at the home:

However, when you click on your logo, this happens:

And it has the audacity to appear even after you’ve successfully enabled your SEO URLs.

Even with the new OpenCart 3.0 update, there’s still no way to edit this from the admin panel.

This is why, we must resort to alternative methods.

The Solutions

There are 2 main methods to remove this from your store’s URL.

Modify your .htaccess file.

Use the OpenCart Events system.

Method #1

To modify your htaccess file, you need to open your OpenCart root directory (with FileZilla for example).

If your SEO URLs are enabled successfully, your htaccess file should already be renamed from .htaccess.txt to just .htaccess.

Edit/View the htaccess file and find this line:

Below it, paste these three lines:

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

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

Method #2

IMPORTANT: This will work only for OpenCart 2.3.0.0+ and 3.0+.

For older OpenCart versions, use Method #1.

Step 1:

Upload a new file in your OpenCart store:

It must contain the following code:

Step 2:

In your database run the following queries:

IMPORTANT: Before running the queries, replace with your OpenCart prefix.

Typically it is oc_ , but you might have changed it with another value. To see your OpenCart prefix, open up the OpenCart file /config.php and find the line saying define('DB_PREFIX', '. ');

DELETE FROM `event` WHERE code='seo_url_common_home';

INSERT INTO `event` (`code`, `trigger`, `action`, `status`) VALUES ('seo_url_common_home', 'catalog/*/before', 'extension/common/seo_url_common_home', 1);

Step 3:

Make sure System > Settings > Edit > tab Server > Use SEO URLs is set to Yes.

Method #2 works for both Apache and NGINX servers, while Method #1 works only on Apache servers.

Now all URLs containing route=common/home will be rewritten to not contain it.

Conclusion

This puts an end to the common/home situation in OpenCart. You should no longer experience the issue and keep your home page URL clean.

opencart – убираем index.php?route=common/home

А заметка на тему как убрать дубль главной страницы которая имеет URL:

Данная заметка будет полезна тем, кто начал оптимизировать под СЕО свой магазин на Opencart и первым делом что нужно сделать это убирать мусор, а точнее дубли страниц коих в OpenCart превеликое множество!

Самое главное при оптимизации это, что бы не было несколько главных страниц. И сейчас работая c магазином и перейдя в код страницы, я вижу что даже несмотря, что я находился на страницы /index.php?route=common/home в коде сайта я вижу тег canonical (о полезности этого удивительного тега Canonical читайте в моей прошлой статье) и можно по факту не убирать этот хвост потому как каноникал это исправит и в поисковую выдачу не попадет эта страницы, я же все таки покажу как это делается правильно!

Для того что бы убрать хвост с главной страницы /index.php?route=common/home (чаще сталкиваетесь с этой ссылкой перейдя на главную страницу кликая на баннере)

  1. откройте файл catalog/controller/startup/seo_url.php
  2. найдите код > elseif ($key == ‘path’) <
  3. вставьте до него следующий код > elseif ($data[‘route’] == ‘common/home’) <
    $url .= ‘/’;
    unset($data[$key]);

В конечном счете должно получится такое:

if ($query->num_rows && $query->row[‘keyword’]) <
$url .= ‘/’ . $query->row[‘keyword’];

unset($data[$key]);
>
> elseif ($data[‘route’] == ‘common/home’) <
$url .= ‘/’;
unset($data[$key]);
> elseif ($key == ‘path’) <
$categories = explode(‘_’, $value);

После этого, обновите страницу и проверьте работоспособность.

PS данная конструкция применима к следующим версиям движка:

Opencart2: 2.0.0.0, 2.0.1.0, 2.0.1.1, 2.0.2.0, 2.0.3.1, 2.1.0.1, 2.1.0.2, 2.2.0.0, 2.3.0.0, 2.3.0.1, 2.3.0.2

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *