Page 1 of 2
SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 7:26 pm
by fbparis
Hi all,
Here is a little hack to get nice seo urls for home, special offers, account, etc.
Just replace the code in system/engine/url.php by this one :
Code: Select all
<?php
final class Url {
public function http($route) {
if ($route == 'common/home') return HTTP_SERVER;
return HTTP_SERVER . (Registry::get('config')->get('config_seo_url') && in_array($route,array('product/special','account/account','account/login','account/logout','checkout/cart','checkout/shipping','information/contact','information/sitemap')) ? $route : 'index.php?route=' . str_replace('&', '&', $route));
}
public function https($route) {
return (HTTPS_SERVER != '' ? HTTPS_SERVER : HTTP_SERVER) . (Registry::get('config')->get('config_seo_url') && in_array($route,array('product/special','account/account','account/login','account/logout','checkout/cart','checkout/shipping','information/contact','information/sitemap')) ? $route : 'index.php?route=' . str_replace('&', '&', $route));
}
}
?>
And in catalog/controller/common/seo_url.php, add this lines just below "if (isset($this->request->get['_route_'])) {" (line 5) :
Code: Select all
switch ($this->request->get['_route_']) {
case '':
case 'product/special':
case 'account/account':
case 'account/login':
case 'account/logout':
case 'checkout/cart':
case 'checkout/shipping':
case 'information/contact':
case 'information/sitemap':
$this->request->get['route'] = $this->request->get['_route_'];
return $this->forward($this->request->get['route']);
}
That's all !
Off course you'll have to set SEO URLS on in your admin pannel and move .httaccess.txt to .htaccess, as explained.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 8:04 pm
by scot80
Just one Question: Which interesting things for Search Engines do you have on a homepage in the account, login or checkout sections?
If you make special offers search engine friendly you have possibly "Duplicated Content". This will downrate your site.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 8:29 pm
by fbparis
You're right
Let say it's user friendly urls. Especialy for the home url.
For real SEO it would be great to implement a unique <link rel="cannonical" href="..." /> generation for all pages to avoid dupplicate entries.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 10:19 pm
by Xsecrets
how exactly would having a seo url for specials cause duplicate content?
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 11:38 pm
by dbstr
Just tried it, and got the following error on v1.3.4. I don't have time to look it up right now, as I'm leaving for dinner shortly, just thought I'd let you know.
PHP Notice: Undefined index: query in /var/www/x/catalog/model/tool/seo_url.php on line 11
Happy New Year!
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Dec 31, 2009 11:50 pm
by scot80
how exactly would having a seo url for specials cause duplicate content?
The products in Specials are also listed in your normal categories so it is
possible a crawler think you have duplicated content. I'm not really sure they handle it this way. But my
Customer don't need seo url's so I prefer to use it only at the products and categories pages.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Jan 01, 2010 12:09 am
by Xsecrets
scot80 wrote:how exactly would having a seo url for specials cause duplicate content?
The products in Specials are also listed in your normal categories so it is
possible a crawler think you have duplicated content. I'm not really sure they handle it this way. But my
Customer don't need seo url's so I prefer to use it only at the products and categories pages.
ahh so you're talking about having /category/product-name and /product-name and manufaturer/product-name I've already hacked all that so all calls to a product only call /product-name
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Jan 01, 2010 10:04 am
by fbparis
Regarding SEO, with or without url rewriting i think the major problem is the multi lang management..
For example if you have 2 languages for your shop, let say french and english, french pages and english pages share the same urls. Search engine crawlers will only be able to index the default language part of the website.
A real seo extension would allow to pass the current language of a page in the url and switch between language versions via a link instead of via a post form.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Jan 01, 2010 11:03 pm
by i2Paq
@ fbparis, your right and many (if not all) shopping-carts have this issue.
I know of a new contribution that has just been beta released for osCommerce that covers this.
It will show the default language urls as: hoppingcart/category/product_name and if you have German as a second language it will show these urls as: hoppingcart/de/category/product_name.
I think this would be the solution for OC as well.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Sun Jan 03, 2010 7:47 am
by christopherdarling
Why do we not just use ?route in .htaccess rather than ?_route_
e.g.
Code: Select all
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?route=$1 [L,QSA]
This seems to work for any URL for me. Is there a particular reason as to why we use ?_route_ for only SEO url's?
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Sat Feb 20, 2010 2:14 am
by electron
@fbparis
Nice, it works for 1.4.0 too but it shows an error at the top- Undefined index...

Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Sat Mar 13, 2010 5:53 pm
by dannowatts
dbstr wrote:
PHP Notice: Undefined index: query in /var/www/x/catalog/model/tool/seo_url.php on line 11
in 1.4.3, the reason it's giving that error is because you need to make sure to include the index.php and route information for it to rewrite it correctly...
incorrect:
Code: Select all
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'product/category&path=' . $result['category_id'])
correct:
Code: Select all
'href' => $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/category&path=' . $result['category_id'])
after you have it formatted correctly, you shouldn't be receiving that error anymore about the undefined index.
hope that helps
rocksteady,
danno~
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Tue Apr 27, 2010 6:39 pm
by dtorras
There's no "system/engine/url.php" in OpenCart 1.4.7 ...
Where is needed to copy that code in 1.4.7?
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu May 13, 2010 2:36 am
by amertad
In 1.14.7 version will work?
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Jun 17, 2010 6:54 pm
by bizbey
I'd like to know that as well. Does this hack work for 1.4.7? Can anyone confirm it?
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Thu Jun 17, 2010 8:45 pm
by Xsecrets
no this will not work for 1.4.4 or newer since the url class was removed.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Tue Dec 21, 2010 3:21 pm
by wandotshop
Could some one summaries this code script need to add or replace? coz i am not understand at all how to make this success...
could someone give me step by step to make seo on:
http://www.domain.com/index.php?route=common/home to be
http://www.domain.com/
http://www.domain.com/index.php?route=account/login to be
http://www.domain.com/login
http://www.domain.com/index.php?route=i ... on/contact to be
http://www.domain.com/contact or contact-us.
could someone do this to me for 1.4.9.1 version..TQ
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Dec 24, 2010 11:16 pm
by tjonnyc
I would like to know how to transform the "
http://www.mysite.com/index.php?route=c ... alcheckout" into the more SEO-friendly "
http://www.mysite.com/checkout" AND force it to use HTTPS, i.e. the final product should be "
https://www.mysite.com/checkout".
I've tried over a dozen solutions listed for transforming a specific URL from HTTP to HTTPS, but none of them work - either make no change, or crash the server on that page.
Any help would be much appreciated!
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Dec 31, 2010 3:28 am
by Chones
Firstly, you don't want your checkout pages SEO friendly. I actually block all robots from indexing my Checkout pages, Account pages and Search results. Why would you want those indexed by Google or Bing? You want your home page, your products, categories and manufacturer pages indexed, nothing else. Google has actually asked shop owners to use robots.txt to stop indexing of shopping carts and checkout pages as it is useless to users and just clogs up their servers. You never know, they may even give you a boost in SERPS if they see you trying to do the right thing.
Secondly, to use HTTPS all you need is to have a certificate installed and then in Admin go to System > Settings and under the Server tag click Yes for Use SSL, and add the SSL URL to the Config file, as it says.
Re: SEO URLS that works (for home, cart, breadcrumps etc)
Posted: Fri Dec 31, 2010 9:34 pm
by Chones
Just in case this is useful, this is my robots.txt file:
Code: Select all
User-agent: *
Disallow: /*?sort
Disallow: /*?route=checkout/
Disallow: /*?route=account/
Disallow: /*?route=product/search
Disallow: /*?page=1
Disallow: /*&create=1
Allow: /
That stops the same category page being indexed for every possible sort option. It stops all checkout pages, account pages and search pages being indexed. It stops a duplicate entry being indexed for a category page when that category page is accessed from page 2 or 3 etc., and it stops the Terms and Conditions and Privacy Policy as accessed from the Checkout stage being indexed.
I'd suggest everyone do this. Google seems to like me and this may be one of the reasons.