ECommerce Insights Blog

Stay on top of it all and get ahead with useful articles, how-tos, tips and tricks on e-commerce.

How To Setup SEO Friendly URLs In OpenCart For Success

How To Setup SEO Friendly URLs In OpenCart For Success

SEO Friendly URLs helps search engines spiders to know more about the content as well us it’s easier for users to remember the page. Proper SEO Friendly URLs helps indexing a lot better and faster manner whereas a suboptimal URLs may miss the SEO juice when due.

Many SEO specialists already verified that the most basic yet common SEO mistake performed by webmasters is related to SEO friendly URLs. This mistake causes less indexing and result in lesser traffic.

Fortunately, OpenCart comes shipped with SEO Friendly URLs in quite configurable manner. Trust me when i say it’s not technical as it may sound. Follow the steps given below to ensure your OpenCart store uses built in SEO friendly URL structure for better indexing of your store, pages and products.

OpenCart on Apache Webserver.

The following steps are for OpenCart running on Apache webserver. If you are using Nginx, Lighttpd or any other webserver just scroll to the bottom.

Rename .htaccess.txt file to .htaccess

Open your preferred ftp client and rename the .htaccess.txt file to .htaccess . This .htaccess file is a apache directive file which will be honored before any other request to a specific page or url. Edit .htaccess file in a text editor to see the following code

#Assuming your store is running at the root directory
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]

If your OpenCart store is residing under any sub-directory you will see something like this

#Assuming your store is running under a sub-directory called shop
RewriteBase /shop/
RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]

Now, tell OpenCart that we are ready to use SEO Friendly URLs. Go to System => Settings => Edit => Click the “Server” Tab and look for radio buttons which says Use SEO URLs. Choose “YES” and save the setting.

That’s it, simple isn’t it? Your store is ready to use SEO Friendly URLs and you can notice them by refreshing the home page and note the new URLs which are formed.

OpenCart on Nginx Webserver

Since, .htaccess file won’t run on Nginx you are required to make some modifications in opencart.conf file manually. Locate opencart.conf file and edit that in your preferred file editor.

It should look something like this

server {
    listen 80;
        #Domain name that is used for OpenCart
	server_name opencart.yourdomain.com;
	access_log /var/log/www/opencart.access-log;

		root /var/www/html/opencart/;
		index index.php index.html index.htm;
	
	# START  Rewrite rules
	rewrite ^/sitemap.xml$ /index.php?route=feed/google_sitemap last;
	rewrite ^/googlebase.xml$ /index.php?route=feed/google_base last;
	rewrite ^/download/(.*) /index.php?route=error/not_found last;
	
       location / {
                try_files $uri $uri/ /index.html;
       }
       location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt)$ {
            access_log        off;
            expires           max;
       }

     # END  Rewrite rules
     
     access_log /var/log/www/opencart.access-log;
     error_log /var/log/www/error.log;

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
  }

}

This will ensure that Nginx will honor the rewrite URL requests. Now, go to System => Settings => Edit => Click the “Server” Tab and look for radio buttons which says Use SEO URLs. Choose “YES” and save the setting.

You are done!

In case you still face any difficulty setting SEO Friendly URLs in OpenCart there in a good paid tool that is available by isenselabs. It will help you configure your OpenCart on Nginx with an ease.