Adding SEO Friendly URL’s to OpenCart

First off, I must give credit where it is due. I got most of my information on OpenCart Clean URL’s from PHP Genious. In this post I will explain how friendly or clean URL’s work in OpenCart.

Clean URL’s are built into OpenCart 1.5. To use SEO URL’s you need to enable them under your stores server settings, rename the .htaccess.txt file and add your SEO keyword for each product and category you create. The keywords will not be created for you. You must also have Apache mod_rewrite turned on. Most web hosts will have this on by default.

Enable SEO URL’s in the OpenCart Admin

The first step is to enable SEO URL’s in your stores admin. Go to the “System” drop-down and click on “Settings”. Locate the store you want to alter and click the “Edit” link off to the right. Finally click the “Server” tab and set the SEO URL’s radio to “Yes” and save your settings.

Rename the .htaccess.txt file

Next you must create an .htaccess file. If you do not create this file your pages will not display. OpenCart provides a file called .htaccess.txt. Rename this file to .htaccess and you will be good to go. If you don’t have this file in your root directory you will need to make your own .htaccess file. The fiel should include the following:

# 1.To use URL Alias you need to be running apache with mod_rewrite enabled. 

# 2. In your opencart directory rename htaccess.txt to .htaccess.

# For any support issues please visit: http://www.opencart.com

Options +FollowSymlinks

# Prevent Directoy listing
Options -Indexes

# Prevent Direct Access to files

 Order deny,allow
 Deny from all

# SEO URL Settings
RewriteEngine On
# If your opencart installation does not run on the main web folder make sure you folder it does run in ie. / becomes /shop/ 

RewriteBase /
RewriteRule sitemap.xml /index.php?route=feed/google_sitemap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

### Additional Settings that may need to be enabled for some servers
### Uncomment the commands by removing the # sign in front of it.
### If you get an "Internal Server Error 500" after enabling any of the following settings, restore the # as this means your host doesn't allow that.

# 1. If your cart only allows you to add one item at a time, it is possible register_globals is on. This may work to disable it:
# php_flag register_globals off

# 2. If your cart has magic quotes enabled, This may work to disable it:
# php_flag magic_quotes_gpc Off

# 3. Set max upload file size. Most hosts will limit this and not allow it to be overridden but you can try
# php_value upload_max_filesize 999M

# 4. set max post size. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value post_max_size 999M

# 5. set max time script can take. uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_execution_time 200

# 6. set max time for input to be recieved. Uncomment this line if you have a lot of product options or are getting errors where forms are not saving all fields
# php_value max_input_time 200

Enter SEO Keywords for URL’s

Finally, you need to enter SEO keywords for every page, information, product and category you want to have URL rewrite. You can find the field for the SEO Keywords under the Data tab when editing and creating items.

Once you have entered the SEO Keywords your URL’w will be working. Now go and enjoy more traffic and happy customers.

46 thoughts on “Adding SEO Friendly URL’s to OpenCart”

  1. Thank you for these clear instructions. Interestingly, if you use an SEO keyword for the product only, you get a nice short URL that just has the product name after the root domain (like a WordPress post). But if you add an SEO keyword for the category, the category’s URL will be shortened and the product URL will contain both the category and the product name. Either way, this is a huge improvement on the standard set-up, and a step that a huge number of e-commerce sites seem to miss.

  2. This is a very slick feature of opencart that can enhance your sites visibility. One thing to watch out for is creating too many category sub levels as each will add to the SEO string. I also recommend that (before going live) you really nail down what the names of your categories and products will be. If you end up making a lot of changes it will take forever for google to update, leaving you with a lot of 404 errors.

  3. Thank you so much for this. Your instructions are very clear and easy to follow.
    I didn’t have a .htaccess file and I received a 403 forbidden error after creating one. I figured the ‘Prevent direct access to files’ make all the php files inaccessible. I changed it to following to get it working.
    # Prevent Direct Access to files

    Order deny,allow
    Allow from all

    I understand what I have done could be a security risk. Is there any other way to prevent direct access to files? Thanks in Advance.

    1. Hello mate,

      Have u ever found a solution for this security issue ? i’m having the same.

      Regards,
      Burhan

    1. You may need to do a bit of googling. I tried to find something for you myself but I dont really know what version of apache or mac you are using.

  4. Your instructions were pretty good till you got the the paragraph about renaming your htaccess file.

    Why does all that text need to be in the file ?
    Some if just seems to be comments.

    1. The text I have in the post is the original file. this is why there are comments. If you already have .htaccess I would worry about it.

  5. I am using Arvixe for a hosting solution. I have implemented both your instructions and other instructions that I found at opencart.com. and I have implemented the rewrite module and have vast experience with Apache and many linux distros on my own physical boxes with no problems. However, with Arvixe it works for a few days, and then BAM! sites stop working.

    So I thought, “ok you didn’t clear you cache and it never worked in the first place.” Tried again, worked for a couple of days and revisited the sites with different VMs etc. and then a couple days go by, and BAM ‘page not available.’

    There are no errors in the logs to even give me an idea of where to start and I don’t have access to the /var/log/apache2/*

    Thoughts? Ideas? Suggestions?

    1. Sounds like you may be having DNS issues. I would recommend contacting your provider and asking about down time. This seems very odd.

  6. The tutorial is great but I try to add the selection keywords and it gave me a 500 and error. Please help hx.

  7. Ok, found the issue. Multiple SEO keywords put in by the customer for every product. Nothing was unique…..

  8. Hi,

    “I received a 403 forbidden error on all pages after creating htaccess. I figured the ‘Prevent direct access to files’ make all the php files inaccessible. I changed it to following to get it working.
    # Prevent Direct Access to files
    Order deny,allow
    Allow from all
    I understand what I have done could be a security risk. Is there any other way to prevent direct access to files? Thanks in Advance.”

    Any solution for this issue yet? i am having the same issue and i’m worried about security of my website…

    1. you may be having these issues due to the user apache is running under and the user that has access to your files.

  9. I’m working on a client;s site and followed your instructions on changing the URLs to SEO-friendly ones. However, the account and checkout links re-direct me to the front page. Can you give some input regarding this issue? I’d greatly appreciate it. Thanks!

  10. Hi
    Thanks for an informative article i hit a problem which turned out to be simple to fix
    after changing name of htaccess my site dissapeared this turned out to be caused by my host “one.com” not allowing the options command however it turned out that they had mod rewrite and followsymlinks enabled on the server so i simply removeed them from the htaccess file and it worked 1st time

    1. Hum, .htaccess is a tricky one as it is also a server side issue and not always something to do with the software (OpenCart) I know this doesn’t help much.

  11. Hi,

    Thank you for this tutorial.
    I followed all the steps like you suggest. I got a 500 Internal Server Error, but I contacted my Support team and they found the solution. I see that the URLs now have the category name, however I get an 404 error message after clicking in the categories
    “The requested URL /fabricantes was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.”

    My hosting support team does not offer help on this issue. Can you suggest how do I solve this.
    Thank you so much for sharing your knowledge.

    Kind regards,
    Ricardo Moura

    1. I wish I could help you here. It could be a multitude of things going on. The only thing I can think of is that you may not have clean/friendly URLs enabled server side which is very unlikely :/

  12. I’m having trouble getting the SEO urls function to work. In your instructions you say:
    “you need to enter SEO keywords for every page, information, product and category you want to have URL rewrite. ”

    If I leave some SEO Keyword fields empty will it cause errors?.

  13. Hi i try to follow your instructions but i get “Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.” before i remove the #
    from the orders.what do i have to do ?

  14. Thanks for the article. I am still having trouble with SEO Url on my site. I can get them to work just fine, but when I do, once a customer logs in, and goes to another page, he is no longer appearing to be logged in except at checkout.

    Say I have a product you must be logged in to Download.
    http://www.thehonorarycitizen.com/accessories?product_id=98
    A customer logs in, and goes back to this page, Download is still not visible, as if he/she never signed in.
    This happens only when SEO Url is turned on, works fine when it is off.
    Its like the SEO Urls are creating new sessions or something.
    How can I correct this? is it a specific re-write rule I have to add in .htaccess?

    Thanks,
    T.

  15. Hey Kevin

    Thanks for the great guide. Managed to get this working with the help of your page. I’ve been browsing the extension store and wondering if anyone has had any experience with this mod
    http://www.opencart.com/index.php?route=extension/extension/info&extension_id=5023
    and am wondering if it’s worth adding to my website. I’ve got approximately 250 products and 20 categories

    Ricardo Moura – I had the same issue as you and it turned out to be the rewrite base in the htaccess file since I’m using /shop/ as my directory

    John

  16. I Had an issue with the site failing and had to comment out the
    # Prevent Direct Access to files

    # Order deny,allow
    # Deny from all
    which cured the rewrite.
    My question is how big a security hole is that and can i plug it?

    Great Article !

  17. hi we buy your opencart seo patch program but we are installing that program I have got a problem. we install your seo and I open my admin panel seo url and chanced my .htacess file but example my contact and sitemap page are don’t execute what can ı do?

Comments are closed.