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.
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:
- SEO Keyword is unique, and no duplicates are allowed.
- 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!
March 27, 2011 at 11:48 am
thanks!
March 30, 2011 at 5:35 pm
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.
May 19, 2012 at 5:36 am
hey actually i want to rewrute the url through htaccess but its not working help me out
March 31, 2011 at 4:48 pm
thankssssssssssssssss
March 31, 2011 at 10:51 pm
THANK YOU! I was tearing out my hair figuring out how to get this to work
March 31, 2011 at 11:51 pm
works! thanks!
April 3, 2011 at 8:48 am
thanks, solved my problem in opencart 1.4.5!
April 18, 2011 at 7:23 pm
This has been so helpful. Thanks!
April 19, 2011 at 9:56 am
Sorry I can not find the .htaccess.txt file
Where is come from? can you give me more details?
April 19, 2011 at 10:03 am
It should be in your base OpenCart folder
May 23, 2011 at 12:25 am
having lots of problem when a customer tries to add to cart, (0 item in cart) any ideas?
August 10, 2011 at 5:31 pm
Thank you so much for your post. It helped confirm my settings.
August 11, 2011 at 10:46 pm
if OpenCart is installed in a subdomin how to edit htaccess ?
sub.open.com/
August 24, 2011 at 2:57 am
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.
August 31, 2011 at 7:40 pm
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!! =)
August 31, 2011 at 7:49 pm
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!!
September 2, 2011 at 1:41 am
Here’s the file for Opencart 1.5.1′s htaccess.txt
November 6, 2011 at 2:34 pm
how to redirect product to http://www.sait.com/product/1 ?
November 29, 2011 at 10:34 am
Thanks, working now properly
November 29, 2011 at 11:03 pm
This is awesome!
For some reason my installation was lacking the .htaccess
I just put the one you pointed and it worked flawlessly.
Thanks!
December 14, 2011 at 6:03 pm
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!
January 19, 2012 at 5:50 am
what will be the base url if i dont have any sub-directory in my website ..
January 19, 2012 at 7:10 am
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
January 19, 2012 at 4:11 pm
The section about sub-directories is only if you have installed OC in a sub-directory. Otherwise, just use the default htaccess file provided.
February 4, 2012 at 6:29 am
Thanks for you this fixed. It is working now. Thanks so much !
February 7, 2012 at 4:09 am
Hey man, thanks a lot for providing the .htaccess file… it doesn’t come with the latest .zip
February 24, 2012 at 3:18 pm
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
February 27, 2012 at 6:02 am
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.
March 27, 2012 at 7:02 pm
It worked. Thanks for the solution…
April 3, 2012 at 1:40 pm
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/
April 11, 2012 at 6:42 pm
Thank You, Thank You. It works! Thanks for the htaccess.txt file. Looked everywhere. Whats up with that.
April 14, 2012 at 7:18 pm
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
May 1, 2012 at 5:44 pm
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
May 12, 2012 at 6:54 am
Thank you, you saved my site
May 31, 2012 at 9:32 am
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
June 9, 2012 at 5:14 am
Thank you!!
July 5, 2012 at 2:40 am
thanks , its works
July 12, 2012 at 5:07 am
its works for me ..Great
July 12, 2012 at 11:05 am
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
August 8, 2012 at 2:25 pm
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
August 12, 2012 at 4:21 am
thanks! works for me
August 12, 2012 at 7:51 am
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?
August 14, 2012 at 5:57 am
keep me informed
August 24, 2012 at 3:19 pm
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
August 27, 2012 at 11:15 am
Many thanks, Sam!
September 4, 2012 at 11:31 pm
thanks for the advice!
September 19, 2012 at 6:17 pm
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,
September 21, 2012 at 2:33 pm
Your htaccess file doesn’t seem to be default. have you tried using the version that comes with Opencart?
September 24, 2012 at 6:40 pm
Thanks. Worked for me!
September 26, 2012 at 5:41 am
Hy,
Great tip. I just saved my self hours of frustration with ur help. Thanks.
October 17, 2012 at 2:28 pm
Thanks so much!
December 4, 2012 at 10:29 am
Thanks, the rewritebase tip did the trick!
December 12, 2012 at 12:42 pm
Thanks…:D
December 14, 2012 at 2:30 am
it works fine with older versions but not with the newest opencart version 1.5.4.1
December 14, 2012 at 3:29 am
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
December 15, 2012 at 6:13 pm
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 ?
December 21, 2012 at 4:39 am
You need to fill up “SEO Keyword” field, that you can find under every category and product.
I hope this will help you out.
December 21, 2012 at 4:36 am
Thanks for saving my time.
January 4, 2013 at 8:31 am
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!
January 6, 2013 at 7:53 am
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
May 31, 2013 at 4:16 pm
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
June 24, 2013 at 6:34 am
Thank you
June 25, 2013 at 1:53 pm
Hey, thanks!! That update fixed it!
March 24, 2014 at 8:09 pm
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
June 16, 2014 at 9:14 am
i have been trying to fix the as per SEO keyword. i have been tried everything, but i dont know why its not working please help can someone can look at it?
plz help me?
June 27, 2014 at 11:02 pm
I’ve spent about 10 hours trying to fix this and I’ve found this post!
God bless you!
August 12, 2015 at 5:19 am
Thanks, it works
November 27, 2015 at 10:49 am
Thanks for help, works for me
December 3, 2015 at 10:42 am
Thanks bro u really too good
May 3, 2016 at 1:11 pm
great!!!!
its working for me..
thanks
June 10, 2016 at 12:08 am
So I am hosting my site on a shared server on Hostgator. From what I can tell Hostgator does not run the apache module mod_rewrite on shared servers. Does this mean that I can not use SEO Urls?