Post by hellogoodbye » Tue May 31, 2011 11:28 am

Hello!

I've downloaded Opencart 1.50 and it looks really nice. Great job guys!

I've started fiddling with it and I already enabled and got the SEO urls for the information pages. But, what about the Contact Us, Returns, Sitemap, Brands, Gift Vouchers, Affiliates, Specials? Why can't those have SEO friendly urls? or all the other links even account, checkout? Some other eCommerce platforms all have aesthetically uniform urls...I want that with OpenCart! How can I get the /index.php?route= to SEO urls? Thanks!
Last edited by i2Paq on Tue Jun 07, 2011 1:59 am, edited 1 time in total.
Reason: Please use [version] TAG in subject!

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by mfive » Wed Jun 01, 2011 10:45 am

... also interested in this.

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by hellogoodbye » Tue Jun 07, 2011 1:19 am

is it possible? can anyone point me in the right direction? Thanks..

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by mfive » Tue Jun 07, 2011 2:36 am

If its crucial you could probably do it in .htaccess using mod_rewrite, no? I'd still like to see if/how its possible using the restored routes class in 1.5...

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by Klimskady » Sat Jun 11, 2011 8:45 am

This is something that I think a lot of people would like.

Active Member

Posts

Joined
Tue Jun 07, 2011 7:57 am

Post by Xsecrets » Sat Jun 11, 2011 10:49 am

How come we all of a sudden have tons of people asking about this? This has been a built in feature of opencart for a LONG time. You need to turn it on in the admin and rename the .htaccess.txt file to .htaccess then change the RewriteBase to / or /yourfoldername/ All of this is outlined in the install file. Are we just getting an influx of people too lazy to bother opening the install file or what?

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 » Sat Jun 11, 2011 11:28 am

Perhaps instead of blaming everyone else you could chalk it up to shitty documentation...

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by kaylamatthews » Sat Jun 11, 2011 12:15 pm

Xsecrets wrote:How come we all of a sudden have tons of people asking about this? This has been a built in feature of opencart for a LONG time. You need to turn it on in the admin and rename the .htaccess.txt file to .htaccess then change the RewriteBase to / or /yourfoldername/ All of this is outlined in the install file. Are we just getting an influx of people too lazy to bother opening the install file or what?
this doesn't take care of pages that aren't products, categories, or information pages. my cart and my account, contact us, etc. are still all gibberish :(

there is a way to route all those links into clean seo-friendly URLs but it would require editing a lot of different source files. the rationale on this board is that those pages aren't important to be indexed by the search engine and some here even block the bots from indexing non-product/category pages....

New member

Posts

Joined
Wed Jun 01, 2011 12:30 pm

Post by Xsecrets » Sat Jun 11, 2011 1:46 pm

mfive wrote:Perhaps instead of blaming everyone else you could chalk it up to shitty documentation...
why bother taking time to write decent documentation people obviously don't read what we do take the time to write.

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 » Mon Jun 13, 2011 12:36 am

I just don't get why instead of being helpful you have to respond like a complete ***. This is NOT in the 1.5 install file. Maybe get down off your high-horse and think about the people that haven't been using OpenCart for as long as you...

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by hellogoodbye » Mon Jun 13, 2011 5:15 am

sorry this turned into a tldr wall of text.

I already turned it on and renamed the .htaccess as stated in the first post. There's sorta two sets of SEO url questions people are asking or maybe are asking about both and don't realize the difference. Some people are asking about the .htaccess/seo urls. While others like me, are asking about the urls with index.php?route, which don't have instructions on how to do it.

I came across another thread that talked about being able to "Customized SEO design of ALL urls" and apparently it's already been added back in.
http://forum.opencart.com/viewtopic.php ... ncart+vote

I'm not a coder so I don't know how...thus I'm asking if anybody else knows how, help each other out in a solution and learn how to do it..etc...Right now, the only lead I have is to look into mod rewrite more to see if it can be achieved.

With .htaccess renamed, the SEO URLs enables:
the Information pages
- About Us
- Delivery Information
- Privacy Policy
- Terms & Conditions
- and any other page you make in Information
- products/categories

It does NOT enable SEO friendly URLs in:
- Home
- Wish List
- My Account
- Shopping Cart
- Checkout
- Contact Us
- Returns
- Site Map

The .htaccess instructions is not in the install.txt. It is somewhere in the Documentations page under one of the categories which you have to click through to find. For new users, it is not easy to find as you don't know the layout of OpenCart and so you wouldn't know in which category it is in. I propose that having a wiki page or changing the documentation layout to maybe a table of contents on top and all the documents on one page so people can read the table of contents, find what they need and get to that section. Another way that may help cut down on repeated posts is to include a saved documententation file with the installation.
Xsecrets wrote:How come we all of a sudden have tons of people asking about this? This has been a built in feature of opencart for a LONG time. You need to turn it on in the admin and rename the .htaccess.txt file to .htaccess then change the RewriteBase to / or /yourfoldername/ All of this is outlined in the install file. Are we just getting an influx of people too lazy to bother opening the install file or what?

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by Xsecrets » Mon Jun 13, 2011 5:38 am

hellogoodbye wrote:sorry this turned into a tldr wall of text.

I already turned it on and renamed the .htaccess as stated in the first post. There's sorta two sets of SEO url questions people are asking or maybe are asking about both and don't realize the difference. Some people are asking about the .htaccess/seo urls. While others like me, are asking about the urls with index.php?route, which don't have instructions on how to do it.
the thing is if you turn off seo url's you'll notice that EVERY url has index.php?route in it.
I came across another thread that talked about being able to "Customized SEO design of ALL urls" and apparently it's already been added back in.
http://forum.opencart.com/viewtopic.php ... ncart+vote
That post was from eons ago, and If I'm not mistaken the url class that was added back in is quite different and I believe someone said not really useful for doing what was mentioned previously.
I'm not a coder so I don't know how...thus I'm asking if anybody else knows how, help each other out in a solution and learn how to do it..etc...Right now, the only lead I have is to look into mod rewrite more to see if it can be achieved.

With .htaccess renamed, the SEO URLs enables:
the Information pages
- About Us
- Delivery Information
- Privacy Policy
- Terms & Conditions
- and any other page you make in Information
- products/categories

It does NOT enable SEO friendly URLs in:
- Home
- Wish List
- My Account
- Shopping Cart
- Checkout
- Contact Us
- Returns
- Site Map
The reasoning that Daniel uses for this is that search engines shouldn't be indexing account shopping cart checkout etc.

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 hellogoodbye » Mon Jun 13, 2011 7:48 am

So if every url has index.php?route, and some can turn on SEO urls. Then, how can I turn every index.php?route to SEO urls? :)

Can't you just use robots.txt to disallow indexing of account, shopping cart, checkout etc?
Xsecrets wrote: the thing is if you turn off seo url's you'll notice that EVERY url has index.php?route in it.

The reasoning that Daniel uses for this is that search engines shouldn't be indexing account shopping cart checkout etc.

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by Xsecrets » Mon Jun 13, 2011 8:17 am

There are a million things you can do, but the fact of the matter is that at this point there is no built in or default or even explained way to make all the index.php?route= go away.

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 amdev » Mon Jun 13, 2011 10:43 am

Hi, u need to modify seo_url.php controller.
I'm tried and work fine for my site.
http://www.laptop-ratings.com/

and see another link like account , checkout , login ...

oc 15x easier than 14x because it just edit 1 file.
In 14x need to edit 2 file and need to load tool/seo_url before to rewite.
But in 15x no need.

there r 2 things to do.
1. edit catalog/controller/common/seo_url.php this is my code(Backup your file before edit)

Code: Select all

<?php
class ControllerCommonSeoUrl extends Controller {
	public function index() {
		// Add rewrite to url class
		if ($this->config->get('config_seo_url')) {
			$this->url->addRewrite($this);
		}
		
		// 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']);
			}
		}
	}
	
	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;
		}		
	}	
}
?>

2.goto url_alias table (PHPmyadmin) and inset

query field = common/home(add another route ie. checkout/cart,checkout/checkout,information/sitemap,...)
keyword = home(or u need).

See my attach file.


Sorry for my bad english.

Good luck sir. :) :) :)

Attachments

seo-url.png

url rewrite - seo-url.png (26.15 KiB) Viewed 67371 times

Last edited by amdev on Mon Apr 08, 2013 8:13 pm, edited 2 times in total.

ร้านค้าออนไลน์
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 hellogoodbye » Mon Jun 13, 2011 11:50 am

Wow thank you for sharing your code! I was not expecting a solution this quick. And your english is fine! I understood what you were saying on one read. :)
amdev wrote:Hi, u need to modify seo_url.php controller.
I'm tried and work fine for my site.
http://www.luxurywatchesbrands.co.cc/home

and see another link like account , checkout , login ...

oc 15x easier than 14x because it just edit 1 file.
In 14x need to edit 2 file and need to load tool/seo_url before to rewite.
But in 15x no need.

there r 2 things to do.
1. edit catalog/controller/common/seo_url.php this is my code(Backup your file before edit)

Sorry for my bad english.

Good luck sir. :) :) :)

New member

Posts

Joined
Wed May 04, 2011 6:33 am

Post by mfive » Mon Jun 13, 2011 12:06 pm

@amdev - thank you for contributing and not criticizing! These forums need more people like you! Awesome post!

New member

Posts

Joined
Sat Jan 29, 2011 9:49 am

Post by uksitebuilder » Mon Jun 13, 2011 5:37 pm

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

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

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

Post by ocpro » Mon Jun 13, 2011 6:55 pm

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

New member

Posts

Joined
Tue Apr 26, 2011 7:57 am

Post by Xsecrets » Mon Jun 13, 2011 8:25 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
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.

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
Who is online

Users browsing this forum: No registered users and 47 guests