SEO URLs for OpenCart Using a “web.config” File on Windows IIS Server

I always suggest Linux hosting for any OpenCart installations. The main OC developers either don’t know much about Windows IIS or neglect to include the necessary SEO URL configuration file for it to work.

This omission results in “not found” 404 (dead link) errors when you visit a page with an SEO URL assigned after enabling SEO URLs in your OpenCart store settings.

Here are the relevant rules from a default OpenCart “htaccess” file…

RewriteEngine On
RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/google_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteRule ^system/download/(.*) index.php?route=error/not_found [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]

And here is a comparable “web.config” file for Windows IIS servers…

<?xml version="1.0"?>
				<rule name="Google Sitemap" stopProcessing="true">
					<match url="^sitemap.xml$"  />
					<action type="Rewrite" url="index.php?route=extension/feed/google_sitemap"  />
				<rule name="Google Base" stopProcessing="true">
					<match url="^googlebase.xml$"  />
					<action type="Rewrite" url="index.php?route=extension/feed/google_base"  />
				<rule name="Downloads Folder" stopProcessing="true">
					<match url="^system/download/(.*)"  />
					<action type="Rewrite" url="index.php?route=error/not_found"  />
				<rule name="Everything Else" stopProcessing="true">
					<match url=".*"  />
					<action type="Rewrite" url="index.php?_route_={R:1}" appendQueryString="true" />

Hope it helps someone else out there!

Feel free to leave a comment 😉

4 thoughts on “SEO URLs for OpenCart Using a “web.config” File on Windows IIS Server

    1. admin Post author

      I rarely use IIS, so if that no longer works 1) make sure your host checks for the web.config file and 2) you may need to update it to reflect your IIS version (if the spec has changed since I wrote this post).

    1. Robert Post author

      Try these rules…

      <rule name="ForceWWW" stopProcessing="true">
      <match url=".*" ignoreCase="true" />
      <add input="{HTTP_HOST}" pattern="^" />
      <action type="Redirect" url="{R:0}" redirectType="Permanent" />
      <rule name="HTTPtoHTTPS" stopProcessing="true">
      <match url="(.*)" ignoreCase="false" />
      <add input="{HTTPS}" pattern="off" />
      <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />

      Be sure to update "" with your actual domain name.


Leave a Reply

Your email address will not be published. Required fields are marked *