RSS Feed

Atom Feed

Most recent entries

 

Comments welcome - just register first.

Login [ Register ]



Auto-login on future visits

Forgot your password?

About Xigent

Xigent specializes in developing and deploying interactive communications strategies for organizations that want to harness the power of the web. Because launching a web site is merely the first step, we help our clients build a roadmap for communicating their message to the target audience and meeting their objectives.

ExpressionEngine: Removing index.php on Windows IIS

Tuesday, November 04, 2008    Bookmark and Share

The engine behind ExpressionEngine is the file index.php. This file appears in the URL in front of the template group name and template name:
xigent.com/dev/index.php/site/article

In some cases you may want to remove index.php from the URL - namely, to make it shorter and cleaner. On Apache, mod_rewrite would accomplish this. But on Windows IIS, the procedure is different. Our preferred method, using the free Ionics ISAPI filter, is fairly simple but does require some server configuration. Below we describe the steps involved.

The ExpressionEngine wiki has a long article on removing index.php. A passing reference to a forum post about the Ionic Isapi filter led us to this method.

Start by getting the Ionic Isapi Rewrite Filter (IIRF) from Codeplex.com. Follow the detailed installation intructions. In short, the filter DLL (IsapiRewrite4.dll) needs to be copied to the web server, along with the settings file (IsapiRewrite4.ini). Then the filter needs to be added under web site properties in the Internet Information Services manager. If you are using the PHP Isapi filter in IIS, then you are familiar with this step.

Next, see the ReadMe file in the IIRF package for setting up IsapiRewrite4.ini. There are many ways to configure IIRF (e.g., RewriteRule, RedirectRule, RewriteHeader, RewriteCond) but for current purposes we want to use RewriteRule. We looked at the method used in the above-referenced forum post:

#Add rules for folders you want to accept without rewriting:
RewriteRule ^/images/(.*)$ /images/$1 [I]
RewriteRule ^/styles/(.*)$ /styles/$1 [I]
RewriteRule ^/themes/(.*)$ /themes/$1 [I]
RewriteRule ^/system/(.*)$ /system/$1 [I]
RewriteRule ^/js/(.*)$ /js/$1 [I]
RewriteRule ^/media/(.*)$ /media/$1 [I]

#This allows querystring to be added to the url (like path=logout)
RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I]

#This removes index.php? from the urls
RewriteRule ^/(.*)$ /index.php?/$1 [I,L]

When we compared the above method with the ‘include’ method described on the EE Wiki, the latter is the easier of the two. Instead of the above, we added these two lines to IsapiRewrite4.ini:

RewriteCond $1 ^(weblog|member|search|site|P[0-9]{2,8}) [I]
RewriteRule ^/(.*)$ /index.php/$1 [L]

This ‘include’ method will rewrite URLs containing the EE directories on the RewriteCond line (separated by the pipe character). The P[0-9]{2,8} handles the EE pagination. Add other folders that should be rewritten. Remove or comment out all other lines (with the possible exception of logging - see the IIRF readme file).

Be sure to put this .ini file in the same directory on the web server as the DLL.

Next, we need to tell ExpressionEngine to remove index.php from the site URL. In the control panel go to System Preferences > General Configuration and remove index.php as the site’s home page. Then make sure ‘Force URL query strings’ is set to ‘No’.

That is all there is to it. If you have other useful implementations of IIRF, let us know.

Posted by xigentdev on 11/04 at 01:40 PM
CMS & Blogs • (0) CommentsPermalink
Page 1 of 1 pages