Post by yadakhov » Thu Mar 04, 2010 1:18 am

Hi all,

I'm new to opencart. Great app by the way. Very easy to install and a nice codebase.

I'm having problem with the clean URL.

What I have done already:
1. make sure mod_rewrite is on on my webserver
2. rename .htaccess.txt to .htaccess
3. enabling SEO url in admin

I don't like address like this:
http://www.example.com/index.php?route=account/login

I want address like this:
http://www.example.com/account/login

Newbie

Posts

Joined
Thu Mar 04, 2010 12:01 am

Post by wgn_white » Sat Mar 06, 2010 7:50 pm

So do I.
Are there any solution for this at the moment?

My Open Cart online shop: Guan8871 Free Shipping Online Shop
My personal blog: Wiguan88.com
Blog where I post my online activities such as web development: PANGERAN.ORG


User avatar
Newbie

Posts

Joined
Sat Mar 06, 2010 1:20 pm
Location - Malaysia

Post by Qphoria » Sat Mar 06, 2010 9:28 pm

All the steps taken are all that is needed. The only other step would be if your store is in a subdirectory like "shop" then you need to change your RewriteBase to /shop/. Otherwise it might be that your server doesn't support mod rewrite

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by wgn_white » Sun Mar 07, 2010 8:13 pm

Qphoria wrote:All the steps taken are all that is needed. The only other step would be if your store is in a subdirectory like "shop" then you need to change your RewriteBase to /shop/. Otherwise it might be that your server doesn't support mod rewrite
Other information like privacy policy is working.
But would it be nice for all url to have a nice url?

My Open Cart online shop: Guan8871 Free Shipping Online Shop
My personal blog: Wiguan88.com
Blog where I post my online activities such as web development: PANGERAN.ORG


User avatar
Newbie

Posts

Joined
Sat Mar 06, 2010 1:20 pm
Location - Malaysia

Post by MulderDSM » Sun Mar 07, 2010 11:32 pm

I have a question on this topic also. Once I made the changes the pages work correctly, but the url doesn't have any ".html" on the end of it and looks a little unfinished.

For example, this is how my URL shows up now:
http://www.thinkdifferentdesigns.com/st ... %20Capitol

but it would look more complete if it looked like this:
http://www.thinkdifferentdesigns.com/st ... pitol.html

Is there any way to add .html to end of the urls?

New member

Posts

Joined
Sat Feb 20, 2010 9:57 pm

Post by rph » Mon Mar 08, 2010 12:53 am

I haven't fully tested it but this seems to work.

/catalog/model/tool/seo_url.php

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query;
to

Code: Select all

return $url_data['scheme'] . '://' . $url_data['host'] . (isset($url_data['port']) ? ':' . $url_data['port'] : '') . str_replace('/index.php', '', $url_data['path']) . $url . $query . (strstr($query, '?') ? '' : '.html');

/.htaccess

Code: Select all

RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
to

Code: Select all

RewriteRule ^(.*)\?*(\.html)$ index.php?_route_=$1 [L,QSA]
EDIT2: Cleaned up the code. Now works with SEO URL and regular URLs in default store.
Last edited by rph on Mon Mar 08, 2010 5:34 pm, edited 1 time in total.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by MulderDSM » Mon Mar 08, 2010 7:33 am

Ryan, thanks, but when using these two mod's I was getting 404 errors, so I changed it back.

New member

Posts

Joined
Sat Feb 20, 2010 9:57 pm

Post by rph » Mon Mar 08, 2010 4:47 pm

You could just cheat and add .html to the end of all your product SEO URLs. You just won't be able to do it for your categories. You really should also remove the space in your SEO URLs and switch them to all lower case.

EDIT: Updated code above works on default store install.

-Ryan


rph
Expert Member

Posts

Joined
Fri Jan 08, 2010 5:05 am
Location - Lincoln, Nebraska

Post by cevarief » Thu Jun 03, 2010 8:01 am

It's wierd that special route like /account/cart, /account/login doesn't work. The seo url only work for routing product, category, info and manufacturing which has alias in the database.
I had to hack the CommonSEOUrl file to make it work by comparing with predifined array ($special_route).

Code: Select all

$parts = explode('/', $this->request->get['_route_']);
$special_route = array('common','information','account','checkout','shipping','product');
if(in_array($parts[0], $special_route) && count($parts) == 2) //must be 2 !
                    return $this->forward(join('/', $parts));
If the url is like http://localhost/opencart/account/login or /product/special, the code will check if the first split of the route is in $special_route and return it as route=account/login, otherwise it will be processed normally.

Active Member

Posts

Joined
Wed Jun 02, 2010 10:52 pm

Post by qahar » Fri Jul 02, 2010 7:52 am

i just want to give suggest on troubleshoot like this, you should mention what version you use. so it's can help another to learn and keep them to not posting the samething on same version OC

User avatar
Expert Member

Posts

Joined
Tue Jun 29, 2010 10:24 pm
Location - Indonesia

Post by tylerdperez » Tue Jun 11, 2013 10:47 am

The solution above didn't work 100% with 1.5.5.1, here is what I did to make it work.

.htaccess from this:

Code: Select all

RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
.htaccess to this:

Code: Select all

RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
public_html/catalog/controller/common/seo_url.php from this:

Code: Select all

return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query;

public_html/catalog/controller/common/seo_url.php to this:

Code: Select all

return $url_info['scheme'] . '://' . $url_info['host'] . (isset($url_info['port']) ? ':' . $url_info['port'] : '') . str_replace('/index.php', '', $url_info['path']) . $url . $query . '.html';

http://www.tylerdperez.com/ Web Development & Search Engine Optimization


User avatar
Newbie

Posts

Joined
Tue Jun 11, 2013 10:43 am
Location - Los Angeles, CA

Post by Qphoria » Tue Jun 11, 2013 8:54 pm

tylerdperez wrote:The solution above didn't work 100% with 1.5.5.1, here is what I did to make it work.

.htaccess from this:

Code: Select all

RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
.htaccess to this:

Code: Select all

RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]
Maybe I'm missing it, but these 2 look identical

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Whyamiy » Sat Mar 01, 2014 11:28 pm

Sorry for bringing up an old thread, but I've found myself in a similar situation where adding the .html suffix to each url would save me having to set up any redirects. Every single url is identical on both websites except my old one finishes .html and the new one doesn't.

The solution from rph is working perfectly for this, however it has broken the pagination. Clicking on page 2, 3 etc brings a 404 not found error. Does anyone know how to fix this please?

Newbie

Posts

Joined
Fri Feb 28, 2014 4:20 am
Who is online

Users browsing this forum: No registered users and 44 guests