How To Solve SEO URLs Not Working in OpenCart

If you’re facing a problem with SEO friendly URLs in OpenCart (experienced with version 1.4.9.1), where all your site’s category or product links redirect you back to your home page, then here’s a solution that may solve your problem.

How To Solve SEO URLs Not Working in OpenCart

Step 1: Enable SEO URLs in OpenCart

Go to System » Server » Use SEO URL’s

Step 2: Rename your .htaccess.txt file to .htaccess by removing the .txt file extension

Use your online file manager, such as the one found in cPanel, or use any FTP software to connect to your site. Vodien provides web hosting plans that provide cPanel, so doing this is really easy. In your OpenCart folder, you should find a file named .htaccess.txt. Rename this file so that it becomes .htaccess.

If you need the htaccess file again, here it is:

OpenCart 1.5.1 htaccess.txt

Step 3: Fill in the SEO Keyword for all the Categories and Products.

Go to Catalog » Products » Data » Seo Keyword. Do take note of the following:

  1. SEO Keyword is unique, and no duplicates are allowed.
  2. There should be no spaces in your SEO Keyword. You should use an underscore or hyphen between each word.

That’s it! Refresh your OpenCart shopping cart website, and you should you the SEO urls working properly.

Update: If OpenCart is installed in a subfolder, e.g. http://www.yourdomain.com/opencart/, you’ll need to modify the .htaccess file located in your OpenCart folder.

Edit the .htaccess file, and look for the following code section, starting from line 18:

# SEO URL Settings
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]

You’ll need to edit line 20, which is:

RewriteBase /

to

RewriteBase /opencart/

After editing, your code should look like this:

# SEO URL Settings
RewriteEngine On
RewriteBase /opencart/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]

Done!

, , , ,

About Site Fixit!

Sam is a professional web designer and web developer. He has over 15 years of experience with web-related technologies, and loves making things work.

View all posts by Site Fixit!

Subscribe

Subscribe to our e-mail newsletter to receive updates.

64 Responses to “How To Solve SEO URLs Not Working in OpenCart”

  1. Annis Says:

    thanks!

    Reply

  2. Andy Says:

    What’s happening? I’m new to this, I stumbled upon this and it’s very helpful and it has helped me out loads. I am hoping to contribute & help other customers like how it’s helped me. Great job.

    Reply

  3. Fred Says:

    thankssssssssssssssss

    Reply

  4. Paddy Says:

    THANK YOU! I was tearing out my hair figuring out how to get this to work

    Reply

  5. Thomas Says:

    works! thanks!

    Reply

  6. Betty Says:

    thanks, solved my problem in opencart 1.4.5!

    Reply

  7. Hammy Says:

    This has been so helpful. Thanks!

    Reply

  8. Melvin Says:

    Sorry I can not find the .htaccess.txt file
    Where is come from? can you give me more details?

    Reply

  9. Bozy Says:

    having lots of problem when a customer tries to add to cart, (0 item in cart) any ideas?

    Reply

  10. Greg Says:

    Thank you so much for your post. It helped confirm my settings.

    Reply

  11. rajer Says:

    if OpenCart is installed in a subdomin how to edit htaccess ?
    sub.open.com/

    Reply

  12. D. Hendrickson Says:

    A big thanks to this helpful article! Didn’t know about Step 3. It should be more descriptive on the product’s data tab within OpenCart. Otherwise, I’m impressed by OC.

    Reply

  13. Diana Says:

    Hi, I really enjoy ready through ur site, lots of helpful info!! I have an opencart site and trying to make my URLs SEO friendly. I’ve read thru forums and looked all thru my website File Manager and can’t find the .htaccess.txt file. I see where it Should be, but it’s not appearing! Some forums have said it may be “hidden” because of the “.” in front of the file, so that may be the case but I dont know how to make it “un-hidden” lol Open cart came as a pre-installed script (thru Elephante) from my hosting account, so with a simple click it was installed! This has been a GREAT help in MANY ways, but seems to be preventing me from a way to search for the .htaccess.txt file (if it’s hidden)- as a lot of people seem to have done, by having the original download from Open Cart to go back and look thru. I hope all this makes sense and you will be able to help me figure this out! My hosting tech support hasn’t been much help on this. Thanks so much!! =)

    Reply

  14. Diana Says:

    Hi again! My hosting “support” is saying my file manager will show all files on the server (hidden or not), so the file must not exist in there. Is this possible, that I could’ve installed Open Cart and the site works fine, but there was no .htaccess.txt file at all? Maybe an easier way for me to solve the SEO friendly URL problem would be to just create my own .htaccess file and insert all the proper text/info into it – would this work? Would you be able to give me all the text to insert into this file? Thank you very much!!

    Reply

  15. Manoj Khyalia Says:

    Thanks, working now properly

    Reply

  16. Dihyan Says:

    This is awesome!
    For some reason my installation was lacking the .htaccess
    I just put the one you pointed and it worked flawlessly.

    Thanks!

    Reply

  17. Miss Quirky Says:

    You are my hero! I’m currently working on a new site for my webshop and this was one thing that just wouldn’t co-operate for me (until I read your tutorial!)
    Thanks so much, have a lovely Christmas!

    Reply

  18. Rama Chandra Shekar Says:

    what will be the base url if i dont have any sub-directory in my website ..

    Reply

  19. Rama Chandra Shekar Says:

    hi

    hope u r doing good .. just had a question on opencart seo-urls .. what ever you have said was absolutely brilliant and works well when i have a sub-directory in place .. and what if i dont have a sub-directory in place .. what will be the base URL.

    this is the example structure given by you..
    RewriteBase /sub-directory/

    assuming that we dont have sub-directory then what would the above statement look like..

    RewriteBase /WHAT IS THE CONTENT HERE/

    PLEASE LET ME KNOW AS SOON AS POSSIBLE ..

    Thanks
    Ram

    Reply

    • Site Fixit! Says:

      The section about sub-directories is only if you have installed OC in a sub-directory. Otherwise, just use the default htaccess file provided.

      Reply

  20. Davet Says:

    Thanks for you this fixed. It is working now. Thanks so much !

    Reply

  21. dcolumbus Says:

    Hey man, thanks a lot for providing the .htaccess file… it doesn’t come with the latest .zip

    Reply

  22. Jean Says:

    Hi Site Fixit,

    I can’t get this to work! I am sure i have done it properly. Any other files that influence the seo url. I have changed some.

    Thnx

    Reply

  23. Steve Says:

    Hello,

    I was able to fix the issue I was having since the cart was using the base of / instead of /shop/

    What I don’t understand is that it does not generate SEO URL’s for all the links.
    I was able to modify some of the URL’s of the site by changing the keyword.

    Maybe this is by design though. I am just use to any website using all or none SEO URL’s.

    Reply

  24. Bill Says:

    It worked. Thanks for the solution…

    Reply

  25. Subash Says:

    Clearly explained and works like that…but I wanted to use SEO friendly URLs for all menus like Home, Account, Logout, Information and other links so I worked around a little bit and got that working…if you want that you may find it http://kcsubash.com.np/seo-friendly-urls-for-opencart/

    Reply

  26. Steve Says:

    Thank You, Thank You. It works! Thanks for the htaccess.txt file. Looked everywhere. Whats up with that.

    Reply

  27. frere Says:

    here is a simple question? How can i check whether this is working or not?
    I have made the changes but don’t kwow how to see if it’s working

    Reply

  28. Fredrik Says:

    Hello,

    thanks for the info, but i cannot get the store to work properly. I am getting correct uls, but when i try to log in to a account, try show in second currency, add to cart and checkout it does not work. Can it have something to do with language or currency??? Read some in the forum

    Reply

  29. Monica Says:

    Thank you, you saved my site :)

    Reply

  30. MikeTwain Says:

    Unfortunately I have been looking for this damn .htaccess.txt file for almost 2 days now and it’s doing my head in, seriously, i will throw my laptop out the window in a second. If I use the file you provided on your site will I have to make any changes to the code inside the file to make it work with my site? Thanks

    Reply

  31. ace Says:

    thanks , its works

    Reply

  32. Gos Says:

    its works for me ..Great

    Reply

  33. Peter Says:

    Some hosting companies have already set some code on there servers.
    You need to remove some code from the original .htaccess file.
    Remove this if you only can view the home page, and other links won’t work if SEO is active in OpenCart:

    Remove from file:

    Options +FollowSymlinks
    Options -Indexes

    Reply

  34. Paul Says:

    Thanks for this article. It quickly solved the headache I was having with SEO URLs.

    In fact this website has been invaluable for solving those little OpenCart teething problems.

    Cheers, Paul

    Reply

  35. Ringo Says:

    thanks! works for me

    Reply

  36. wouter Says:

    Hi,

    I have opencart installed in subdir, but want to have the url as /

    So I have this htaccess in / :

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

    does not work. any suggestions?

    Reply

  37. IT support Says:

    keep me informed

    Reply

  38. Andrei M Says:

    Hi there,

    Can you help me with redirections? I want to redirect my old links to my new opencart links.
    I use “redirect 301 /old-link http://www.mysite.ro/new-link” and the website automatically transform the link to “http://www.mysite.ro/new-link?_route_=old-link”.

    What should I do?

    Thanks,
    Andrei M

    Reply

  39. Yossarian Says:

    Many thanks, Sam!

    Reply

  40. aaa Says:

    thanks for the advice!

    Reply

  41. Anooshka Says:

    Hi,
    I followed what you said to have SEO URLs, but when I want to change the .htaccess file to what you said, the only things that I see is as follows:
    RewriteEngine off

    suPHP_ConfigPath /home/thermo/public_html/php.ini

    order allow,deny
    deny from all

    I can chgange the rewrite engine to on, but don’t see other lines that need to be changed.
    Now my problem is if I enable SEO URL on my website and there is anything at SEO Keywords section, then the page won’t come up and just sends me an error. Would you please help me with this?
    Thanks a lot,

    Reply

  42. Satya Thakur Says:

    Thanks. Worked for me!

    Reply

  43. rom Says:

    Hy,

    Great tip. I just saved my self hours of frustration with ur help. Thanks.

    Reply

  44. Matt Says:

    Thanks so much!

    Reply

  45. Mischa Says:

    Thanks, the rewritebase tip did the trick!

    Reply

  46. galih Says:

    Thanks…:D

    Reply

  47. Mitch Says:

    it works fine with older versions but not with the newest opencart version 1.5.4.1

    Reply

  48. Mitch Says:

    Sorry, need to add, my store is in a sub folder or sub domain, hence I used;
    RewriteBase /mydomain/nl/
    or
    RewriteBase /nl.mydomain/
    (even tried to place another .htaccess file into the “nl” folder (which shouldn’t be done, I know) but it won’t work

    I have the main shop in RewriteBase /mydomain/, that works

    I also tried to add a second Rewrite base to the main .htaccess, hence, having;
    RewriteBase /mydomain/
    RewriteBase /nl.mydomain/
    or
    RewriteBase /mydomain/
    RewriteBase /mydomain/nl/

    but this won;t work neither.

    Any solution to that if you have a main store and then several additional stores set up like me?

    Cheers

    Reply

  49. satya Says:

    Hi,

    I have enabled SEO URL from system settings and enabled mod rewtite still i am not getting the SEO links….all links are working but they are like old one…

    what could be the issue ?

    Reply

    • farhan ahmed Says:

      You need to fill up “SEO Keyword” field, that you can find under every category and product.

      I hope this will help you out.

      Reply

  50. farhan ahmed Says:

    Thanks for saving my time. :)

    Reply

  51. Adrian Says:

    Hello,
    I have a problem which takes me all the time to solve it but without success.
    I can’t add to cart on prodact page but in home page is ok and in category list is ok too. I don’t know what to do. Here yoy are my .htaccess
    # 1.To use URL Alias you need to be running apache with mod_rewrite enabled.
    RewriteOptions inherit
    # 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 [L]
    RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
    RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

    RewriteEngine On
    Redirect 301 /www.rafaelplants.ro http://rafaelplants.ro
    Redirect 301 /rafaelplants.ro/index.php http://rafaelplants.ro
    Redirect 301 /rafaelplants.ro/index.php?route=common/home http://rafaelplants.ro

    ### 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

    # 7. disable open_basedir limitations
    # php_admin_value open_basedir none

    All the best!

    Reply

  52. shabeg Says:

    I have an issue which i am trying to solve since a long time. A help here would be great.
    I am hosting my site using xampp on local server. The store front for opencart works fine on my PC. But when when my friend wants to open it using my IP the page doesn;t load properly it kind of gives a listing of all the products etc. And when i click any of the product it gives an error:-

    Object not found!

    The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

    If you think this is a server error, please contact the webmaster.

    Error 404

    localhost
    Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.7

    Reply

  53. Rodolpho Says:

    Thanks mate

    The detail about adding the sub-folder to .htaccess is key. Most sites out there forget to add the slash ‘/’ after the sub-folder name, and that makes a big difference, meaning, the shop will keep throwing 404s. It happened in my case. When I added the slash at the end, everything went back to normal.

    Keep up the good work.

    RA

    Reply

  54. Sebin Says:

    Thank you :)

    Reply

  55. Marie Pizzer Says:

    Hey, thanks!! That update fixed it! :)

    Reply

  56. eyal Says:

    Hello

    Please help, 1 month i have been trying to fix this url writing seo . ive tried everything i dont know why its not working please help can someone can look at it?

    thanks

    Reply

Leave a Reply