Scroll

Problem with direct URLs on IIS servers

If you are running IIS and you are facing problems with opening website URL's directly (404 error appears) - you definitely should try the solution below. 

Since our CMS generates page code dynamically, URL rewriting is required for proper work of website navigation. On Linux servers URL rewriting is performed via Apache mod_rewrite module and all rewrite rules are stored in .htaccess file. The .htaccess is an Apache configuration file, that is why it does not work on IIS.

So on IIS some analogue module should be used (this one for example). On IIS7 you can import the .htaccess rules without any problems. If you have access to IIS manager, just enter it, go to your domain and open the section Url-rewrite rules. Then use the Import button (you should copy rules from our .htaccess file attached) and your rules will be automatically imported to your web.config file (on IIS web.config file performs the same function as .htaccess on Apache).

Here is a copy of the rewrite rules stored in our .htaccess. Please be advised, that some rules are commented by default, in order to uncomment them you should remove hash sign (#).

<IfModule mod_rewrite.c> 
RewriteEngine On

## uncomment the following line, if you are having trouble 
## getting no_script_name to work 
RewriteBase /

## remove trailing slash 
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteCond %{REQUEST_URI} ^(.+)/$ 
#RewriteRule ^(.+)/$ $1 [R=301,L]

## turn off index.html, it is for offline mode 
RewriteRule ^.*index.html$ index.php [QSA]

## no, so we redirect to our front web controller 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule>

Assuming you have rewrite module enabled on your server, you should import the rules above to your web.config file. But first those rules should be converted in order to work properly. The detailed instruction on how to accomplish this is available by this link

In case you do not have access to IIS manager, you can find complete web.config file attached. Please place this file to your template's root folder. Assuming you have rewrite module installed, direct URLs should work properly. 

If this solution was helpful for you, please share your experience with us. Your feedback is much appreciated!

Have more questions? Submit a request

Comments