Post by ocpro » Mon Jun 13, 2011 8:54 pm

Yeah, its not ideal, but does have some benefits. For example, should a product/category name be changed for whatever reason, old URL's will still work regardless of the changes, where as with opencart's default method it wouldn't. It also means there's no chance of duplicate URL's accidentally being set for say an info page and a category, as many people do without realising

New member

Posts

Joined
Tue Apr 26, 2011 7:57 am

Post by uksitebuilder » Mon Jun 13, 2011 11:21 pm

My thoughts on this would be to have all the standard pages etc re-written

For categories/products etc, to keep the SEO Keyword entry boxes so a user can enter their own, but if these are left blank by the user when adding a product or category, then the name or title is used (after checking it isn't already in use).

This therefore gives the user the option to overwrite (use their own) seo keyword, and at least have a fall-back in case they forget to enter one.

In addition to this and also important is to have Canonical URL Meta Tag in place so site's ranking isn't affected with multiple page name paths going to the same document.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Xsecrets » Mon Jun 13, 2011 11:54 pm

uksitebuilder wrote:
In addition to this and also important is to have Canonical URL Meta Tag in place so site's ranking isn't affected with multiple page name paths going to the same document.
canonical urls are already in place for products and categories.

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


Guru Member

Posts

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

Post by mfive » Tue Jun 14, 2011 3:46 am

Xsecrets wrote: well it's nice that you have the contact pages etc rewritten, and that you can be lazy and not create aliases for your other stuff, but I hate url schemes that use the category and product numbers in them. To be honest I like the default urls better than that.
I kind of agree... Why couldn't they just be http://site.com/laptops-and-notebooks/ or http://site.com/components?

Why can't each category be given a "slug", and then each product be given a "slug" - so that you could go to (for example):
http://www.yourstore.com/category-slug/product-slug

Is that not possible?

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by ocpro » Tue Jun 14, 2011 5:07 am

For the very reasons above, it's to improve performance and consistency. I don't really see the big deal personally that they have a few numbers in it too. You still get all of your keywords in the url. As for what you want mfive, that is actually how opencart works by default, the only difference being that you have to manually add all of your slugs (or use an seo keyword gen tool) which will require checking manually for duplicates

New member

Posts

Joined
Tue Apr 26, 2011 7:57 am

Post by psyhlo » Wed Jun 29, 2011 4:14 pm

@amdev

it worked like a charm thanks allot :)

Newbie

Posts

Joined
Wed Jun 29, 2011 4:12 pm

Post by zaycho » Thu Jul 14, 2011 2:28 pm

ocpro wrote:I've actually been working on an automatic url rewriter for 1.5. You can see the demo here
- SNIPPED -

You can change pretty much any route to a different one, such as information/contact to just contact, so that it reads
http://yoursite.com/contact

Notice that all of the category, product and information URL's are in a standard format, and you don't have to write any of these url's at all. For any of the urls such as route=account/login it will become yoursite.com/account/login unless you edit them

To try out the url customisation, go to
- SNIPPED -
username: demo
password: demo

and go to SYSTEM > UBER SEO

This will be available soon from the extension store (commercial mod). If anyone is interested in purchasing this before hand you can contact me directly
Hi ocpro! Have you already released your Uber SEO extension?

New member

Posts

Joined
Thu May 12, 2011 4:02 am

Post by jtothed » Fri Jul 15, 2011 4:18 pm

Thanks for the SQL queries... You're missing http://www.yousite.com/index.php?route= ... ation_id=6 (Delivery information; you can find this in the sitemap)

I tried to work it based on the sample SQL queries, but the "=6" got me confused.

Another problem that I noticed is that the old links -- "/index.php?route=" still functions as normal page instead of redirecting to the new SEO friendly urls... Any workaround?
uksitebuilder wrote:Nice one amdev

Here is my SQL for anyone wishing to import via phpMyAdmin

Code: Select all

INSERT INTO url_alias (query, keyword) VALUES ('common/home', '');
INSERT INTO url_alias (query, keyword) VALUES ('account/wishlist', 'wishlist');
INSERT INTO url_alias (query, keyword) VALUES ('account/account', 'my-account');
INSERT INTO url_alias (query, keyword) VALUES ('checkout/cart', 'shopping-cart');
INSERT INTO url_alias (query, keyword) VALUES ('checkout/checkout', 'checkout');
INSERT INTO url_alias (query, keyword) VALUES ('account/login', 'login');
INSERT INTO url_alias (query, keyword) VALUES ('account/logout', 'logout');
INSERT INTO url_alias (query, keyword) VALUES ('account/order', 'order-history');
INSERT INTO url_alias (query, keyword) VALUES ('account/newsletter', 'newsletter');
INSERT INTO url_alias (query, keyword) VALUES ('product/special', 'specials');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/account', 'affiliates');
INSERT INTO url_alias (query, keyword) VALUES ('checkout/voucher', 'gift-vouchers');
INSERT INTO url_alias (query, keyword) VALUES ('product/manufacturer', 'brands');
INSERT INTO url_alias (query, keyword) VALUES ('information/contact', 'contact-us');
INSERT INTO url_alias (query, keyword) VALUES ('account/return/insert', 'request-return');
INSERT INTO url_alias (query, keyword) VALUES ('information/sitemap', 'sitemap');
INSERT INTO url_alias (query, keyword) VALUES ('account/forgotten', 'forgot-password');
INSERT INTO url_alias (query, keyword) VALUES ('account/download', 'downloads');
INSERT INTO url_alias (query, keyword) VALUES ('account/return', 'returns');
INSERT INTO url_alias (query, keyword) VALUES ('account/transaction', 'transactions');
INSERT INTO url_alias (query, keyword) VALUES ('account/register', 'create-account');
INSERT INTO url_alias (query, keyword) VALUES ('product/compare', 'compare-products');
INSERT INTO url_alias (query, keyword) VALUES ('product/search', 'search');
INSERT INTO url_alias (query, keyword) VALUES ('account/edit', 'edit-account');
INSERT INTO url_alias (query, keyword) VALUES ('account/password', 'change-password');
INSERT INTO url_alias (query, keyword) VALUES ('account/address', 'address-book');
INSERT INTO url_alias (query, keyword) VALUES ('account/reward', 'reward-points');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/edit', 'edit-affiliate-account');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/password', 'change-affiliate-password');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/payment', 'affiliate-payment-options');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/tracking', 'affiliate-tracking-code');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/transaction', 'affiliate-transactions');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/logout', 'affiliate-logout');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/forgotten', 'affiliate-forgot-password');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/register', 'create-affiliate-account');
INSERT INTO url_alias (query, keyword) VALUES ('affiliate/login', 'affiliate-login');
Please let us know if any pages have been missed

Newbie

Posts

Joined
Fri Jul 15, 2011 4:12 pm

Post by Xsecrets » Fri Jul 15, 2011 9:31 pm

jtothed wrote:Thanks for the SQL queries... You're missing http://www.yousite.com/index.php?route= ... ation_id=6 (Delivery information; you can find this in the sitemap)

I tried to work it based on the sample SQL queries, but the "=6" got me confused.
if it has an information_id=X in it then it means that you can edit it from the admin just find the information page with that title and add an SEO keyword.

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


Guru Member

Posts

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

Post by jtothed » Fri Jul 15, 2011 10:36 pm

Found it; thanks! How about duplicate pages?

Newbie

Posts

Joined
Fri Jul 15, 2011 4:12 pm

Post by Xsecrets » Fri Jul 15, 2011 10:49 pm

jtothed wrote:Found it; thanks! How about duplicate pages?
there is no solution for that, but it's not a big deal. Simply don't send no seo urls to google.

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


Guru Member

Posts

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

Post by jtothed » Fri Jul 15, 2011 10:52 pm

That makes a lot of sense. Thanks again!

Newbie

Posts

Joined
Fri Jul 15, 2011 4:12 pm

Post by uksitebuilder » Sat Jul 16, 2011 2:18 am

Xsecrets wrote:
uksitebuilder wrote:
In addition to this and also important is to have Canonical URL Meta Tag in place so site's ranking isn't affected with multiple page name paths going to the same document.
canonical urls are already in place for products and categories.
Not for categories they aren't

Fix:
Open: catalog/controller/product/category.php

Find:

Code: Select all

			$this->document->setKeywords($category_info['meta_keyword']);
Add After:

Code: Select all

			$this->document->addLink($this->url->link('product/category', 'path=' . $category_id), 'canonical');

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Xsecrets » Sat Jul 16, 2011 6:53 am

uksitebuilder wrote:
Xsecrets wrote:
uksitebuilder wrote:
In addition to this and also important is to have Canonical URL Meta Tag in place so site's ranking isn't affected with multiple page name paths going to the same document.
canonical urls are already in place for products and categories.
Not for categories they aren't

Fix:
Open: catalog/controller/product/category.php

Find:

Code: Select all

			$this->document->setKeywords($category_info['meta_keyword']);
Add After:

Code: Select all

			$this->document->addLink($this->url->link('product/category', 'path=' . $category_id), 'canonical');
as far as I know there is not any situation where you get duplicate urls on the categories though.

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


Guru Member

Posts

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

Post by uksitebuilder » Sat Jul 16, 2011 2:26 pm

On subcats and third level cats

Site.com/subcat

Is the same as

Site.com/cat/subcat

Or

Site.com/thirdlevelcat

Is the same as

Site.com/cat/subcat/thirdlevelcat

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by jtothed » Sat Jul 16, 2011 2:31 pm

So the code above will fix this issue? I have noticed the same too and I think it is duplicate content in the eyes of the search engines...
uksitebuilder wrote:On subcats and third level cats

Site.com/subcat

Is the same as

Site.com/cat/subcat

Or

Site.com/thirdlevelcat

Is the same as

Site.com/cat/subcat/thirdlevelcat

Newbie

Posts

Joined
Fri Jul 15, 2011 4:12 pm

Post by hellogoodbye » Sun Jul 17, 2011 2:46 am

Thanks for the quick fix, uksitebuilder. Though it would be better if the categories didn't do that. Are there benefits to having the subcategories without the parent categories work?

I made a vqmod for it.

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by amdev » Mon Jul 25, 2011 10:06 am

There r many people PM to me about solution for oc149x.
I'm tested with 1495 it work.
amdev wrote:Ok follow these steps.(Backup your systems before)
1.edit this file.

Code: Select all

\catalog\controller\common\seo_url.php
copy my code and paste to your file.

Code: Select all

<?php
class ControllerCommonSeoUrl extends Controller {
   public function index() {
      
      // Decode URL
      if (isset($this->request->get['_route_'])) {
         $parts = explode('/', $this->request->get['_route_']);

         $route = "";
         
         foreach ($parts as $part) {
            $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
            
            if ($query->num_rows) {
               $url = explode('=', $query->row['query']);

               if(count($url) > 1){
               
               if ($url[0] == 'product_id') {
                  $this->request->get['product_id'] = $url[1];
               }
               
               if ($url[0] == 'category_id') {
                  if (!isset($this->request->get['path'])) {
                     $this->request->get['path'] = $url[1];
                  } else {
                     $this->request->get['path'] .= '_' . $url[1];
                  }
               }   
               
               if ($url[0] == 'manufacturer_id') {
                  $this->request->get['manufacturer_id'] = $url[1];
               }
               
               if ($url[0] == 'information_id') {
                  $this->request->get['information_id'] = $url[1];
               }
               }else{
                  $route = $url[0];
               }
            } else {
               $this->request->get['route'] = 'error/not_found';   
            }
         }
         
         if (isset($this->request->get['product_id'])) {
            $this->request->get['route'] = 'product/product';
         } elseif (isset($this->request->get['path'])) {
            $this->request->get['route'] = 'product/category';
         } elseif (isset($this->request->get['manufacturer_id'])) {
            $this->request->get['route'] = 'product/manufacturer/product';
         } elseif (isset($this->request->get['information_id'])) {
            $this->request->get['route'] = 'information/information';
         }else {
            $this->request->get['route'] = $route;
         }

         
         if (isset($this->request->get['route'])) {
            return $this->forward($this->request->get['route']);
         }
      }
   }
   
  }
?>
2.edit this file.

Code: Select all

\catalog\model\tool\seo_url.php

Code: Select all

<?php
class ModelToolSeoUrl extends Model {
 public function rewrite($link) {
      if ($this->config->get('config_seo_url')) {
         $url_data = parse_url(str_replace('&', '&', $link));
      
         $url = '';
         
         $data = array();
      
         parse_str($url_data['query'], $data);
         
         foreach ($data as $key => $value) {
            if (($key == 'product_id') || ($key == 'manufacturer_id') || ($key == 'information_id')) {
               $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($key . '=' . (int)$value) . "'");
            
               if ($query->num_rows) {
                  $url .= '/' . $query->row['keyword'];
                  
                  unset($data[$key]);
               }               
            } elseif ($key == 'path') {
               $categories = explode('_', $value);
               
               foreach ($categories as $category) {
                  $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = 'category_id=" . (int)$category . "'");
            
                  if ($query->num_rows) {
                     $url .= '/' . $query->row['keyword'];
                  }                     
               }
               
               unset($data[$key]);
            }elseif ($key == 'route') {
               $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE `query` = '" . $this->db->escape($value) . "'");
            
               if ($query->num_rows) {
                  $url .= '/' . $query->row['keyword'];
                  
                  unset($data[$key]);
               }               
            }
         }
      
         if ($url) {
            unset($data['route']);
         
            $query = '';
         
            if ($data) {
               foreach ($data as $key => $value) {
                  $query .= '&' . $key . '=' . $value;
               }
               
               if ($query) {
                  $query = '?' . trim($query, '&');
               }
            }

            return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
         } else {
            return $link;
         }
      } else {
         return $link;
      }      
   }   
   
  }
?>
3.goto your database Run this mysql command.

Code: Select all

    INSERT INTO url_alias (query, keyword) VALUES ('common/home', '');
    INSERT INTO url_alias (query, keyword) VALUES ('account/account', 'my-account');
    INSERT INTO url_alias (query, keyword) VALUES ('checkout/cart', 'shopping-cart');
    INSERT INTO url_alias (query, keyword) VALUES ('checkout/checkout', 'checkout');
    INSERT INTO url_alias (query, keyword) VALUES ('account/login', 'login');
    INSERT INTO url_alias (query, keyword) VALUES ('account/logout', 'logout');
    INSERT INTO url_alias (query, keyword) VALUES ('account/order', 'order-history');
    INSERT INTO url_alias (query, keyword) VALUES ('account/newsletter', 'newsletter');
    INSERT INTO url_alias (query, keyword) VALUES ('product/special', 'specials');
    INSERT INTO url_alias (query, keyword) VALUES ('product/manufacturer', 'brands');
    INSERT INTO url_alias (query, keyword) VALUES ('information/contact', 'contact-us');
    INSERT INTO url_alias (query, keyword) VALUES ('information/sitemap', 'sitemap');
    INSERT INTO url_alias (query, keyword) VALUES ('account/forgotten', 'forgot-password');
    INSERT INTO url_alias (query, keyword) VALUES ('account/download', 'downloads');
    INSERT INTO url_alias (query, keyword) VALUES ('account/return', 'returns');
    INSERT INTO url_alias (query, keyword) VALUES ('account/transaction', 'transactions');
    INSERT INTO url_alias (query, keyword) VALUES ('account/register', 'create-account');
    INSERT INTO url_alias (query, keyword) VALUES ('product/search', 'search');
    INSERT INTO url_alias (query, keyword) VALUES ('account/edit', 'edit-account');
    INSERT INTO url_alias (query, keyword) VALUES ('account/password', 'change-password');
    INSERT INTO url_alias (query, keyword) VALUES ('account/address', 'address-book');
'account/account' this is a route.
'my-account' this is your keyword can edit it if u want.

4.goto

Code: Select all

\catalog\controller\common\header.php
You will see this code

Code: Select all

<?php   
class ControllerCommonHeader extends Controller {
	protected function index() {

//Remember *** load this model before use seo

			$this->load->model('tool/seo_url');//I'm add this line in index function.


    	if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['language_code'])) {
			$this->session->data['language'] = $this->request->post['language_code'];
		
			if (isset($this->request->post['redirect']) && strpos($this->request->post['redirect'], HTTP_SERVER) !== false) {
				$this->redirect($this->request->post['redirect']);
			} else {
//Call $this->model_tool_seo_url->rewrite($link) to rewrite url like this.
				$this->redirect($this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=common/home'));
//Old redirec is $this->redirect(HTTP_SERVER . 'index.php?route=common/home');
			}
    	}		
		
		if (($this->request->server['REQUEST_METHOD'] == 'POST') && isset($this->request->post['currency_code'])) {
      		$this->currency->set($this->request->post['currency_code']);
			
			unset($this->session->data['shipping_methods']);
			unset($this->session->data['shipping_method']);
				
			if (isset($this->request->post['redirect']) && strpos($this->request->post['redirect'], HTTP_SERVER) !== false) {
				$this->redirect($this->request->post['redirect']);
			} else {
//This was solved as well.
				$this->redirect($this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=common/home'));
			}
   		}

Then look to bottom code around line 85.

Code: Select all

		$this->data['home'] = HTTP_SERVER . 'index.php?route=common/home';
		$this->data['special'] = HTTP_SERVER . 'index.php?route=product/special';
		$this->data['contact'] = HTTP_SERVER . 'index.php?route=information/contact';
    	$this->data['sitemap'] = HTTP_SERVER . 'index.php?route=information/sitemap';
    	$this->data['account'] = HTTPS_SERVER . 'index.php?route=account/account';
		$this->data['logged'] = $this->customer->isLogged();
		$this->data['login'] = HTTPS_SERVER . 'index.php?route=account/login';
		$this->data['logout'] = HTTP_SERVER . 'index.php?route=account/logout';
    	$this->data['cart'] = HTTP_SERVER . 'index.php?route=checkout/cart';
		$this->data['checkout'] = HTTPS_SERVER . 'index.php?route=checkout/shipping';

replace to.

Code: Select all

		$this->data['home'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=common/home');
		$this->data['special'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=product/special');
		$this->data['contact'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=information/contact');
    	$this->data['sitemap'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=information/sitemap');
    	$this->data['account'] = $this->model_tool_seo_url->rewrite(HTTPS_SERVER . 'index.php?route=account/account');
		$this->data['logged'] = $this->customer->isLogged();
		$this->data['login'] = $this->model_tool_seo_url->rewrite(HTTPS_SERVER . 'index.php?route=account/login');
		$this->data['logout'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=account/logout');
    	$this->data['cart'] = $this->model_tool_seo_url->rewrite(HTTP_SERVER . 'index.php?route=checkout/cart');
		$this->data['checkout'] = $this->model_tool_seo_url->rewrite(HTTPS_SERVER . 'index.php?route=checkout/shipping');
		
Finished.

Sory for my bad english. :laugh: :laugh: :laugh:

Thanks.

Amdev.
***Note: because 148-149 don't use url class. So u need to load

Code: Select all

$this->load->model('tool/seo_url');
before to rewrite any link.

ร้านค้าออนไลน์
OpenCart Thailand Support Forum
How to Upgrade oc1.5 to 2.0.1.1
Upgrading OpenCart From v.1.4 or v.1.5 to V.2.2 Step by step


User avatar
Active Member

Posts

Joined
Fri Nov 27, 2009 3:40 pm
Location - Bangkok - Thailand

Post by crashfellow » Tue Jul 26, 2011 7:40 am

I found this on another post:
User-agent: *
Disallow: /*?sort
Disallow: /*?route=checkout/
Disallow: /*?route=account/
Disallow: /*?route=product/search
Disallow: /*?page=1
Disallow: /*&create=1
Allow: /

Could we alter this to remove any SEO issues with the re-writen url's?

Such as:
Disallow: /account/
Disallow: /cart/

Newbie

Posts

Joined
Tue Jul 26, 2011 6:56 am

Post by Melanie » Tue Aug 02, 2011 8:08 pm

Hi,

Okay I have done this mod on version 1.5.1

However slight problem, the image on the contact us page is not coming up (the on that needs to be entered to submit the form).

I think it is to do with "index.php?route=information/contact/captcha"

Can anyone help?
Do I have to make another modication somewhere?

Thanks,
Mel

New member

Posts

Joined
Tue Mar 30, 2010 9:39 am
Who is online

Users browsing this forum: No registered users and 159 guests