Pages

Tuesday, August 18, 2009

Using Drupal with Microsoft URL Rewrite Module for IIS 7

Views

Using Drupal with Microsoft URL Rewrite Module for IIS 7




It seems that only two years ago there was very limited choice when looking for a URL Manipulation tool for IIS, especially ones that can easily be adapted to work with mod_rewrite rules which is the only rewrite engine most PHP applications support. These days however there are several URL manipulation tools for IIS that support the Apache .htaccess/mod_rewrite syntax including the new URL Rewrite Module for IIS 7 from Microsoft. In this guide we'll look at just how easy it is to use this new module from Microsoft with the very popular PHP based Drupal CMS.


There only real prerequisites for using the Microsoft URL Rewrite Module is that you are using IIS 7, other than than you just need the actual Rewrite module which can be downloaded here.


Once you have the URL Rewrite module installed, the next step is to open the IIS Manager and browse to your Drupal website. With this site selected you should now be presented with a pane similar to below with a series of icons. Double click the URL Rewrite Module icon to continue.

Select the URL Rewrite Module


You'll now enter the URL Rewrite module settings. All we'll be doing for this task is using the import function, so click on the import rules link at the top right hand corner as shown below.

URL Rewrite administration screen


Next step is to select the mod_rewrite .htaccess file to import. To do this click on the browse button on the right hand side of the configuration file field.


Import Rules

Select your Drupal .htaccess file and then click the import button to import your rules as shown below.


Import .htaccess file

Once the .htaccess file is imported click the apply link in the top right hand corner of the screen, and you'll be returned to the main URL Rewrite module screen. From here all you need to do is rename the module to something more descriptive (e.g. Drupal) and make sure the rule is enabled from the context menu using the right mouse button.



Rename and enable rule

The final two steps you'll need to do is modify the request filtering in IIS so that functions like multiple word search strings work properly without giving you a 404 error, and to manually force Drupal to use Clean URL's as when using Microsoft's URL Rewrite module the REQUEST_URI variable is not supported as it is when using ISAPI Rewrite 3 from Helicontech.


To modify the request filter in IIS 7 open you ApplicationHost.config file and search for the following;


<requestFiltering


Then add this before the closing ">" character;


allowDoubleEscaping="true"



Save this, and your IIS config is complete.


Next, open your Drupal settings.php file and place the following code on a new line.


$conf['clean_url'] = 1; // 1 enables, 0 clears clean_url


Once you save this you should be all set to use Drupal's clean URL feature on IIS 7 using the new Microsoft URL Rewrite module. Any comments or feedback on the article, please feel free to post a comment below. If you'd like any specific support for your environment, then please post a new thread in the forums.

0 comments:

Post a Comment

 

Web Design Company karimnagar, Web Designing warangal, Logo Design Company nizamabad, Indian Website Design Company, maddysoft.co.in