Post by fbparis » Thu Dec 31, 2009 7:26 pm

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.
Last edited by i2Paq on Sat Mar 13, 2010 6:31 pm, edited 1 time in total.
Reason: Topic moved

Newbie

Posts

Joined
Thu Dec 31, 2009 4:38 pm


Post by scot80 » Thu Dec 31, 2009 8:04 pm

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.

Newbie

Posts

Joined
Fri Nov 06, 2009 12:14 am
Location - Germany

Post by fbparis » Thu Dec 31, 2009 8:29 pm

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.

Newbie

Posts

Joined
Thu Dec 31, 2009 4:38 pm


Post by Xsecrets » Thu Dec 31, 2009 10:19 pm

how exactly would having a seo url for specials cause duplicate content?

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by dbstr » Thu Dec 31, 2009 11:38 pm

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!

Request Reviews v1.0 released.


Newbie

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by scot80 » Thu Dec 31, 2009 11:50 pm

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.

Newbie

Posts

Joined
Fri Nov 06, 2009 12:14 am
Location - Germany

Post by Xsecrets » Fri Jan 01, 2010 12:09 am

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

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by fbparis » Fri Jan 01, 2010 10:04 am

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.

Newbie

Posts

Joined
Thu Dec 31, 2009 4:38 pm


Post by i2Paq » Fri Jan 01, 2010 11:03 pm

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

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

UPGRADE to 2.x: Contemplate before thou begins!

Our FREE search: Find your answer FAST!.

BUGs?: Known BUGS for All OC Versions.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by christopherdarling » Sun Jan 03, 2010 7:47 am

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?

Christopher Darling - Web Design Bristol



Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by electron » Sat Feb 20, 2010 2:14 am

@fbparis

Nice, it works for 1.4.0 too but it shows an error at the top- Undefined index... :(

Newbie

Posts

Joined
Wed Feb 17, 2010 10:01 pm

Post by dannowatts » Sat Mar 13, 2010 5:53 pm

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~

Newbie

Posts

Joined
Tue Nov 10, 2009 11:40 am

Post by dtorras » Tue Apr 27, 2010 6:39 pm

There's no "system/engine/url.php" in OpenCart 1.4.7 ...

Where is needed to copy that code in 1.4.7?

Newbie

Posts

Joined
Tue Apr 27, 2010 6:36 pm

Post by amertad » Thu May 13, 2010 2:36 am

In 1.14.7 version will work?

opcart.ir


User avatar
Newbie

Posts

Joined
Fri Apr 30, 2010 1:04 am
Location - tehran - iran

Post by bizbey » Thu Jun 17, 2010 6:54 pm

I'd like to know that as well. Does this hack work for 1.4.7? Can anyone confirm it?

Newbie

Posts

Joined
Thu May 27, 2010 11:34 pm

Post by Xsecrets » Thu Jun 17, 2010 8:45 pm

no this will not work for 1.4.4 or newer since the url class was removed.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Newbie

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by wandotshop » Tue Dec 21, 2010 3:21 pm

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

Newbie

Posts

Joined
Wed Oct 06, 2010 12:15 am

Post by tjonnyc » Fri Dec 24, 2010 11:16 pm

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!

Newbie

Posts

Joined
Tue Dec 21, 2010 5:05 am

Post by Chones » Fri Dec 31, 2010 3:28 am

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.

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Newbie

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London

Post by Chones » Fri Dec 31, 2010 9:34 pm

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.

http://scarletandjones.com/
http://sharpdressedman.co.uk/
http://coffincompany.co.uk/
http://horsesculptures.co.uk/
If I've helped you out, why not buy me a beer? http://craigmurray.me.uk


User avatar
Newbie

Posts

Joined
Wed Mar 24, 2010 9:07 pm
Location - London
Who is online

Users browsing this forum: No registered users and 7 guests