Tuesday, March 25, 2014

Drupal migration to IIS 7, Fixing URL Redirection, 404 error for Drupal

After migrating Drupal site from Apache to IIS, there was an issue with URL Redirection and ended up in 404 error.

To fix the issue, import the .htaccess file to IIS. Below are the steps...

1) Make sure URL Redirection is installed on your server
2) Once you have the URL Rewrite module installed, the next step is to open the IIS Manager and browse to your Drupal website.
3) Double click the URL Rewrite icon to continue
4) 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.
5) 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.
6) Select your Drupal .htaccess file and then click the import button to import your rules.
7) 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.

(Applying above things fixed my issue. Below are some more steps that I found in another blog)

----------------------------
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;


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.