With the final release of Drupal 4.7 there seems to be some new code added (was not present in any RC) which tries to test for Clean URL compatibility which causes some issues when using ISAPI Rewrite on IIS with Drupal. The ISAPI rules I use work fine with Drupal once I bypass this test, the problem is that the method used to test for clean URL's is dependent on .htaccess.

Problem No.1

This new code present on lines 291~300 (inclusive) in system.module tests for clean URL's, but this code is what generates the test URL;

'<a href ="'. str_replace('?q=', '', url('admin/settings', '', 'clean_url')) .'">'. t('Run Clean URL Test') .'</a>'

Problem with this code is that ISAPI Rewrite does not have the ability to check for file existance like .htaccess does. This means that when using the .htaccess the index.php portion of the string is removed, but not when using ISAPI rewrite. The results of which means you'll get a URI stem like this when using IIS with ISAPI Rewrite;

/drupal/index.phpadmin/settings&

And this when using Apache with the Drupal .htaccess rules;

/drupal/admin/settings&

Obviously the IIS one is not going to work.

Problem No.2

The fact that Drupal tests specfically for a .htaccess based rule isn't so much a problem, as it has always been this way. The difference is that you used to be able to execute this SQL directly against your Drupal database using PHPMyAdmin (or similar) to effectively bypass that test;

SELECT * FROM variable v WHERE v.name = 'clean_url';
UPDATE variable SET value = 's:1:"1";' WHERE name = 'clean_url';

However, now you are unable to enable Clean URL's in Drupal even if you manually set it to be enabled directly in the database as system.module now overides that setting if the Clean URL test fails (which it always will with ISAPI Rewrite on IIS).

Solution

I'll try and take a closer look in the next few days to write a specific rule for ISAPI Rewrite for this new test, but currently the only solution for those using Clean URL's with IIS and ISAPI Rewrite is to manually remove/comment out lines 291~300 (inclusive) in system.module (or download attached modified version) which effectively removes Clean URL testing. This will revert the Clean URL setting to the same way it was in all the RC versions, so be sure that your ISAPI Rewrite rules are setup or your site will be cactus.

To make things more straight forward for us IIS users, would it please be possible to place this Clean URL test in an if statement that checks the _SERVER["SERVER_SOFTWARE"] PHP variable for the existance of Apache before being executed? That way the test still works for Apache users, but us IIS users don't have to go digging through code and stripping out bits just to get Clean URL's to work.

CommentFileSizeAuthor
system.module57.38 KBbrashquido
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Sorry for the last minute change. As a quickfix put $conf['clean_url'] = 1 to the end of your settings.php.

brashquido’s picture

Hi Károly,

I tried putting $conf['clean_url'] = 1 at the very end of my settings.php file, but it resulted in getting a blank page. I'll do a search around and see what I can find.

sepeck’s picture

I am using clean URL's on IIS with with this line
$conf['clean_url'] = 1; // 1 enables, 0 clears clean_url
on my IIS site. Now I broke my ISAPI_Rewrite settings so paging doesn't work but I think that's my fault.

www.blkmtn.org

brashquido’s picture

Sorry, my mistake;

$conf['clean_url'] = 1 is a lot different to $conf['clean_url'] = 1<strong>;</strong>.

Cheers

magico’s picture

Status: Active » Closed (works as designed)

Clean URL test has a few problems in certain conditions that can only be surpased by admin knowledge and setting a settings.php variable.

In this case, is a "by design" problem.

MikeOConnor’s picture

I got the whole clean_URLs shebang working a couple minutes ago; Drupal 5, IIS v6. Here's the cookbook;

- Step 1 -- get ISAPI_Rewrite going (i'm using the paid version so i can set the rules in the root directory of the virtual web site rather than for the whole machine)

- Step 2 -- put an httpd.ini file for ISAP_Rewrite in the root directory of the site, include the following rules in the file;

# Accept a url with the following extensions and pass them through unchanged.
RewriteRule (.*.gif|.*.png|.*.jpg|.*.pdf|.*.js|.*.css) $1 [I,L]

# Make URLs sane
RewriteRule /index.php.* $0 [I,L]
RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

- Step 3 -- add the following line to the settings.php file for the site (I put it at the end)

$conf['clean_url'] = 1;

- Step 4 -- modify the database to toggle on the clean-url variable in the VARIABLE table (note; this is one of the "I'm not sure I really needed to do this" steps). I did this with the MySQL Control Center. Double-clicked the VARIABLE table to open it, scrolled to the bottom of the table, selected "insert record" from the Query menu and then;

set the "name" field to --->>> clean_url
set it's value to --->>> s:1:"1";

- Step 5 -- modify the system.module file to spoof it into *NOT* testing to see if if clean_urls will work (that's what this thread is all about). Since the shift to Drupal 5 munged up the line numbers for me, the way I did it was to set the default value of the "test to see if clean_urls will work" variable to "everything's ok" instead of "nope, it's not" which then made the program skip the test. Do a search in the file to find the old code;

'#default_value' => variable_get('clean_url', 0),

Replace it with;

'#default_value' => variable_get('clean_url', 1),

Note the "0" changing to "1" at the end, that's what spoofs the test.

Step 6 -- start refreshing a few pages on your site, or travelling to new ones, and see how it's going. I fooled myself by going to cached pages a few times. So go to a page you haven't been to, or refresh the page. Clean URLs abound, I hope. They do for me. I'm a happy camper.

I'm not sure you absolutely have to do everything I did -- but that gaggle of steps is what made it work for me. Clearly, this isn't for the faint of heart so I wouldn't do this unless you're pretty confident. The nice thing is that all of these steps are reversable. :-)

rubensans’s picture

Thanks you MikeOConnor for your contribution !!!

I have been testing a lot and you only need to do:

1.- Put in HELICON ISAPI REWRITE this:

# Accept a url with the following extensions and pass them through unchanged.
RewriteRule (.*.gif|.*.png|.*.jpg|.*.pdf|.*.js|.*.css) $1 [I,L]

# Make URLs sane
RewriteRule /index.php.* $0 [I,L]
RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

2.- Add the following line to the settings.php file for the site (I put it at the end)

$conf['clean_url'] = 1;

Best Regards.

hass’s picture

Someone able to update the wrong / incomplete Handbook under http://drupal.org/node/46429 please?

RobRoy’s picture

Project: Drupal core » Documentation
Version: 4.7.0 »
Component: system.module » Admin Guide
Assigned: Unassigned » RobRoy
Category: bug » task
Status: Closed (works as designed) » Fixed

Fixed that handbook page. Look okay?

hass’s picture

Status: Fixed » Active

thank you for the handbook update... Asside this ISAPI rules are buggy

i got page not found errors since i use them:
http://localhost/drupal/index.php?q=cron.php

hass’s picture

other URLs maybe broken, too.

update.php
xmlrpc.php

brashquido’s picture

Hi All,

I wrote an article on my website about this;

http://www.iis-aid.com/articles/how_to_guides/using_drupal_clean_urls_wi...

About the the only thing these ISAPI Rewrite rules don't do is enable the clean url radio button. Still working on that.

RobRoy’s picture

If we get some feedback saying that those rewrite rules work, I'll incorporate them into the handbook page. I don't have IIS to test, so I'm just going off public feedback.

hass’s picture

@brashquido: Your variant isn't working at all. Aside if you document something that should be cut and paste then please use PRE.

Error: Bad regular expression at lines 4 - 4.

# Accept a url with the following directories and pass them through unchanged. 
RewriteRule /(?:misc|files|modules|themes|sites|uploads|)/(.*) $0 [I,L] 

# Make URLs sane 
RewriteRule /cron\.php $0 [I,L] 
RewriteRule /index\.php.* $0 [I,L] 
RewriteRule /update\.php.* $0 [I,L] 
RewriteRule /robots\.txt $0 [I,L] 
RewriteRule /xmlrpc\.php $0 [I,L] 
RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L] 
RewriteRule /(.*?)(?:/page_(\d+))? /index.php\?q=$1?2&page=$2: [I,L] 
RewriteRule /(.*) /index.php\?q=$1 [I,L]
brashquido’s picture

Thanks for the catch on the formatting issue Hass. Those rules are working for me though, they are a direct copy & paste from my production server. Not sure why you are getting a Bad regular expression error, I'll take a look at it.

hass’s picture

@brashquido: the bug seems the pipe after uploads.

ISAPI Rewrite config if Drupal is installed in a subdirectory (Solution requires ISAPI_Rewrite >=2.9 Build 63)

[ISAPI_Rewrite]

# You must change/remove prefixes if Drupal is not installed in a subdirectory
# Specify namespaces with UriMatchPrefix - DO NOT CHANGE ORDER
UriMatchPrefix /drupal

# Accept a url with the following directories and pass them through unchanged. 
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane 
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# deactivate following line if "robotstxt" module is installed
#RewriteRule /robots\.txt.* $0 [I,L]

# specify namespaces with UriFormatPrefix - DO NOT CHANGE SUXXX ORDER
UriFormatPrefix /drupal

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*?)(?:/page_(\d+))? /index.php\?q=$1?2&page=$2: [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

# reset namespaces to default
UriMatchPrefix
UriFormatPrefix

ISAPI Rewrite config if Drupal is installed in Webservers Root

[ISAPI_Rewrite]

# Accept a url with the following directories and pass them through unchanged. 
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane 
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# deactivate following line if "robotstxt" module is installed
#RewriteRule /robots\.txt.* $0 [I,L]

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*?)(?:/page_(\d+))? /index.php\?q=$1?2&page=$2: [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]
brashquido’s picture

*slapshead* Of course it is. I didn't get any time really to look at it yesterday, but after copying and pasting my rules into my article I removed an entry for the AWStats "js" directory after uploads. I obviously neglected to remove associate pipe symbol.

While we are at it the second last rule should be removed or deactivated. This was an attempt to get fully Clean URL's when using the paging module (sample_article/page1 instead of sample_article/?page=0,1) but I never got around to finishing it as I read that using the paging module can lead to search engine penalization as they see the pages as duplicate data. Thanks for the help there Hass, I think the rules should be pretty clean now. The only thing I haven't been able to resolve or had a lot of time to look into is the "Clean URL Test" in the Drupal admin.

[ISAPI_Rewrite]

# Accept a url with the following directories and pass them through unchanged.
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# deactivate following line if "robotstxt" module is installed
#RewriteRule /robots\.txt.* $0 [I,L]

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]
RobRoy’s picture

If we get confirmation on an exact ruleset, I'll put it in that handbook page. @hass can you confirm that works? Anyone else on IIS?

hass’s picture

yes, the last and the two versions i posted are working, but as brashquido said the RewriteRule /(.*?)(?:/page_(\d+))? /index.php\?q=$1?2&page=$2: [I,L] should be removed from my versions. please document the "drupal in subdirectory" version as well. maybe without the "suxxx" comment :-).

seakayjay’s picture

I'm using IIS too. The rules provided work for me as well. But has anyone test this with banner.module as well? I've tried adding two rules identical to cron.php for the two banner files which are placed on the root.

RewriteRule /banner_db\.php $0 [I,L]
RewriteRule /banner_file\.php $0 [I,L]

but at the log message, it stated that the banner_db.php is not found.

hass’s picture

The bad side of the Helicon ISAPI_Rewrite is, this config needs to be extended by every filename that is located in the webroot... maybe you have a problem with the CacheClockRate 3600 that isn't available in the lite version if i remember correctly. i tried your rule in the regex tester and it works. i don't know why it shouldn't work.

Aside, why are this banner files located in the webroot? i thought this is only a core file location... shouldn't this files in the modules/banner directory? i never used / tryed this banner module...

hass’s picture

the rules need to be extended for Drupal 5:

# Make URLs sane
RewriteRule /install\.php $0 [I,L]

if not, Drupal 5 install isn't working... now we should really happen all bugs in this rules finally fixed... :-(

brashquido’s picture

Yep, that should about cover it.

RobRoy’s picture

Can you post the entire ruleset in a comment so I can make sure to copy and paste it into the page? Then, I'll delete the comments.

hass’s picture

Here it is RobRoy...

ISAPI Rewrite config if Drupal is installed in Webservers Root

[ISAPI_Rewrite]

# Accept a url with the following directories and pass them through unchanged.
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /install\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# activate rewriting for custom modules (for e.g. banner.module)
RewriteRule /banner_db\.php $0 [I,L]
RewriteRule /banner_file\.php $0 [I,L]

# deactivate rewriting for custom modules (for e.g. robotstxt.module)
RewriteRule /robots\.txt.* $0 [I,L]

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

ISAPI Rewrite config if Drupal is installed in a subdirectory (Solution requires ISAPI_Rewrite >=2.9 Build 63)

[ISAPI_Rewrite]

# You must change/remove prefixes if Drupal is not installed in a subdirectory
# Specify namespaces with UriMatchPrefix - DO NOT CHANGE ORDER
UriMatchPrefix /drupal

# Accept a url with the following directories and pass them through unchanged.
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /install\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# activate rewriting for custom modules (for e.g. banner.module)
RewriteRule /banner_db\.php $0 [I,L]
RewriteRule /banner_file\.php $0 [I,L]

# deactivate rewriting for custom modules (for e.g. robotstxt.module)
RewriteRule /robots\.txt.* $0 [I,L]

# specify namespaces with UriFormatPrefix - DO NOT CHANGE ORDER
UriFormatPrefix /drupal

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

# reset namespaces to default
UriMatchPrefix
UriFormatPrefix

...sometimes i wish to have a permission to correct/change outdated or wrong books :-).

FiReaNGeL’s picture

Can you confirm that these settings work with imagecache? I'm currently experiencing problems using IIS and your settings; imagecache doesnt seem to do anything (not creating thumbnails, etc). Imagecache is highly dependant on url rewrite and is a critical module for most sites (its the only viable image handling solution right now).

brashquido’s picture

Never actually used it, but I'll give it a try.

OpusDei-1’s picture

The ISAPI rules work great... until I try to go to my docuwiki or phpmyadmin. Having a heckuva time rewriting the rules to allow for that. Any ideas? The docuwiki and phpmyadmin folders are in the root of the webserver, as it is drupal is returning page not found.

brashquido’s picture

If you are using the free version of ISAPI Rewrite, then you only have one httpd.ini file which applies to all your websites. In this file you'll need to set some rules so that these rules only apply to the domains you want them to. You can find it in the guide I wrote here;

http://www.iis-aid.com/articles/how_to_guides/using_drupal_clean_urls_wi...

localhost@2006.planet-soc.com’s picture

Have you ever looked at the Ionics Isapi Rewrite Filter (IIRF)?

It has a new version that has just been released under a new license in February 2007 under the: Microsoft Permissive License (MS-PL). It supports PCRE directly within the configuration file and, from the looks of it, all the main rewriting settings specified in the comments above will also work with it. In fact, changes to the configuration file take place immediately after it is saved. For an example of functionality, I copied the first line from the .htaccess file and whenever a user requests to view a file such as block.module I have it redirect to the home page using the following code (as I couldn't determine an easy way to deny access, I don't believe this is exploitable, but feel free to prove me wrong):

RewriteRule (\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$ /index.php [R]
redamo’s picture

I second using Ionics Isapi Rewrite Filter. It's free, it has source code available and doesn't have the limitations of the Lite Helicon filter described above. I share the rules that I made, feel free to modify them or use them.

RewriteLog E:\temp\iirfLog.out
RewriteLogLevel 3
RewriteFilterPriority HIGH

# Accept a url with the following directories and pass them through unchanged.
RewriteRule ^/misc/(.*)$ /misc/$1 [I,L]
RewriteRule ^/files/(.*)$ /files/$1 [I,L]
RewriteRule ^/modules/(.*)$ /modules/$1 [I,L]
RewriteRule ^/themes/(.*)$ /themes/$1 [I,L]
RewriteRule ^/sites/(.*)$ /sites/$1 [I,L]
RewriteRule ^/uploads/(.*)$ /uploads/$1 [I,L]
RewriteRule ^/css/(.*)$ /css/$1 [I,L]
RewriteRule ^/images/(.*)$ /images/$1 [I,L]

# for modules that provide their own js (tinymce,img assist etc)
RewriteRule ^(.*\.js)$ $1 [I,L]
RewriteRule ^(.*\.gif)$ $1 [I,L]
RewriteRule ^(.*\.png)$ $1 [I,L]
RewriteRule ^/modules/tinymce/(.*)$ /modules/tinymce/$1 [I,L]

# Make URLs sane
RewriteRule ^/cron\.php$ /cron.php [I,L]
RewriteRule ^/index\.php\?q\=(.*)$ /index.php?q=$1 [I,L]
RewriteRule ^/update\.php\?op\=(.*)$ /update.php?op=$1 [I,L]
RewriteRule ^/update\.php /update.php [I,L]
RewriteRule ^/xmlrpc\.php /xmlrpc.php [I,L]

RewriteRule ^/robots\.txt /robots.txt [I,L]

# Handle query strings on the end
RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L]

# now pass through to the generic handler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]

Cheers!

robray’s picture

Hey all,

this is Rob Ray (robray not robroy who is also in this thread. heh...)

Also, if you are using Urchin to track on your site and you have the __utm.js and __utm.gif files stored in drupals root you'll need to add a rule for __utm.js and __utm.gif.

I was banging my head on this for a while.

blur’s picture

Check out IIS Mod-Rewrite. It makes Drupal clean permalinks work on IIS exactly the way they work on Apache (it uses the same .htaccess rules). Here is a very useful link with detailed info on how to set it up: Clean Permalinks for IIS using .htaccess

IMO, it's BY FAR the best solution for IIS. Note it's commercial though.

hass’s picture

Are you working for this company? The best and most popular is ISAPI_Rewrite as i know.

blur’s picture

Hass, apparently you haven't used IIS Mod-Rewrite, and apparently you haven't noticed that ISAPI_Rewrite is trying to copy IIS Mod-Rewrite... You need a little update, check out ISAPI_Rewrite v3 beta...

hass’s picture

We are using ISAPI_Rewrite and if you search the net, you will get 90% Helicon results and some other bad ones, less development, buggy, beta, not working, no support or expensive and bad. I know about v3.0 and this will be very helpful, but i don't think they have copied the idea from IIS Mod-Rewrite. It's more that customers request this Apache functionality on a move to IIS.

"IIS Mod-Rewrite" have copied this from Apache...

However, someone able to remove this backlink SPAM comments, please? They are OT here.

blur’s picture

Ok, this is getting ridiculous and really OT, but it's my time to ask you, are you working for ISAPI_Rewrite?

Take a look at these two links that I saw in a forum. I hope you will finally understand who is copying who. Literally copying...

http://www.micronovae.com/ModRewrite/ref/Compatibility.html
http://www.helicontech.com/isapi_rewrite/doc/compatibility.htm

FYI, I've been using ISAPI_Rewrite for years, but now I'm switching my clients to IIS Mod-Rewrite simply because it's a lot better and saves me a great deal of time. It's up to you if you want to waste your time using ISAPI_Rewrite and waiting for a horrible beta to become a stable product...

Just one question, have you EVER tried IIS Mod-Rewrite?

ellasisking’s picture

I am using the rules described in post #31 by redamo (with IIRF), however I have my drupal installation in a sub directory.

so, going to www.mysite.com redirects to www.mysite.com/drupal1

using the rules in #31 only work for drupal isntallations running in the root directory. How do I modify to run in subdirectory drupal1?

hass’s picture

see #25

ellasisking’s picture

#25 is for the Helicon solutions isn't it? Would the exact same reg expressions work with the Ionic solution.....if so I cna't get it to work, i get file not found errors when navigating to these links?

hass’s picture

This thread is only about Helicons ISAPI_Rewrite.

hass’s picture

Status: Active » Fixed

Helicon have released ISAPI_Rewrite version 3.x for a long time that works out of the box with drupals .htaccess. It was a little bit buggy in the last versions (.38 to .42), but v3.1.43 seems to be ok.

Additional CleanURL check is done in a different way in D6+. So no need to keep this open for the next year...

hass’s picture

Helicon have released ISAPI_Rewrite version 3.x for a long time that works out of the box with drupals .htaccess. It was a little bit buggy in the last versions (.38 to .42), but v3.1.43 seems to be ok.

Additional CleanURL check is done in a different way in D6+. So no need to keep this open for the next year...

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

jcbrew’s picture

Haas,

It's not working out of the box for me. I just bought ISAPI 3 and installed it today - I can not get my drupal sites to enable clean urls.

Do I need to make any changes to the .htaccess file or settings.php? I'm a bit confused

jcbrew’s picture

Status: Closed (fixed) » Active
hass’s picture

Status: Active » Closed (fixed)

No, nothing needs to be changed - really nothing. It simply works like Apache mod rewrite with D6. In D5 only you need to add the extra line $conf['clean_url'] = 1; to settings.php.

I'm running many sites on IIS with ISAPI 3. Only make sure you are using the latest version... there were many bugs in past, but this have all been fixed... I told Helicon ~10 releases it is not working with Drupal as expected and they have fixed all issues I came across in 3.1.0.43. If I remember correctly version from 3.1.0.32 to 3.1.0.42 are not working as expected with Drupal. I know for sure 3.1.0.43 is working well and I'm also running 3.1.0.53. I haven't tested the light version with subdirectories...

Maybe you have a permission issue.

jcbrew’s picture

Thank you for the reply. I added the code you gave me to setting.php. After I saved and started navigating the site I kept getting 403 error. I know it's because ISAPI 3 is not set up correct.

I contacted my hosting company that installed ISAPI3 for me and asked them to verify that it was running / configured properly. This was their reply:

Hello
You can check if your application running or not, you need create simple .htaccess file with mod_rewrite rules and test it

if everything setup correctly rules will work if not -> you will get error_page 500

I made sure the current Drupal .htaccess file had the proper permissions and it still didn't work.

Can someone tell me how to create a simple page that will reference a simple .htaccess file? This way I can verify that the ISAPI3 installation was not done properly.

I guess the best thing to do would be uninstall ISAPI3 and reinstall myself. But I don't want to do that until I verify that it doesn't work with the simple page setup.

Thanks for any help...

jcbrew’s picture

I installed ISAPI Rewrite Version 3 (The full version) onto my server. I wasn't able to get Drupal to recognize it so I did a little test. I created a new directory and created two files and entered

DirectoryIndex newmain.html

into the .htaccess file then I browsed to the directory where the .htaccess file resides expecting to be taken to newmain.html but was instead taken to index.html (old default page). So I suppose this tells me the ISAPI Rewrite is not working.

I have also made sure the permissions were set to both the directory and the .htaccess file. I got to the point were I gave EVERYONE full access to the directory and .htaccess file.

So, assuming it's not working. Can someone help me figure what I need to do to get this working. I bought the full version in hopes that I wouldn't have to worry about all this stuff.

My server is a Windows machine with Windows 2003 Web Edition IIS6. I am running both Drupal 6 and 5. ISAPI is not working with either version.

Please let me know if there any more info needed.

jcbrew’s picture

Status: Closed (fixed) » Active
hass’s picture

Turn on debugging in ISAPI3 and then look into the logs. Maybe you find something. Otherwise Helicon Support and the Helicon Forum are very helpful. Your issue is not Drupal related.

This is off topic here.

hass’s picture

Status: Active » Closed (fixed)
jcbrew’s picture

Thanks for throwing my issue to the side. I can't get anyone to help. Helicon Support is of no help they want to blame the hosting company and the hosting company wants to blame "Drupal" and the people at Drupal don't care.

hass’s picture

I assure you - this must be a server issue! ISAPI 3 should be ~100% Apache compatible and it works FOR SURE with Drupal out of the box. We don't need to care about anything here. The Drupal .htaccess is working with Apache. If there is something broken (nevertheless it was in past) it is a Helicon issue - not Drupal. I worked out many bugs with Helicon and they fixed all bugs. There is no bug i'm aware about - as it runs fine on 3 boxes (XPSP2, 2 x Win2K3 both 32bit) I've installed it.

Make sure "NETWORK SERVICE" have at minimum change access to the .htaccess files (RTFM). And as already said - TURN ON debugging mode in ISAPI. It could show you many things - maybe this could help - if not Helicon can tell you with this logs. I'm pretty sure the source of your issues is the hosting company or their buggy config if you don't have the hands on it... you cannot do anything wrong and you don't need to change any .htaccess as ISAPI3 (only version 3) provides Apache compatibility what means you DON'T need to change anything. This Apache compatibility should be *the* case WHY you are using version 3.

PS: This is a closed documentation case.

interestingaftermath’s picture

Component: Admin Guide » Correction/Clarification
Status: Closed (fixed) » Active

I have installed ISAPI_Rewrite 3 FULL and have copied the following into the Helicon Manager into my site's config tab (which is my site's root .htaccess file)

# Accept a url with the following directories and pass them through unchanged.
RewriteRule /(?:misc|files|modules|themes|sites|uploads)/(.*) $0 [I,L]

# Make URLs sane
RewriteRule /cron\.php $0 [I,L]
RewriteRule /index\.php.* $0 [I,L]
RewriteRule /install\.php.* $0 [I,L]
RewriteRule /update\.php.* $0 [I,L]
RewriteRule /xmlrpc\.php $0 [I,L]

# activate rewriting for custom modules (for e.g. banner.module)
RewriteRule /banner_db\.php $0 [I,L]
RewriteRule /banner_file\.php $0 [I,L]

# deactivate rewriting for custom modules (for e.g. robotstxt.module)
RewriteRule /robots\.txt.* $0 [I,L]

RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L]
RewriteRule /(.*) /index.php\?q=$1 [I,L]

I have then added the $conf['clean_url'] = 1 to my settings.php file.

What next? Should Clean URLs work? Each link I click it tries to take me to a clean URL page but I get Page Not Found. Any help would be appreciated. I cannot continue working on this site until this is fixed because the client does not want it to launch without clean urls. I miss apache. :(

hass’s picture

Status: Active » Closed (fixed)

No, don't do this. The rules are ONLY for ISAPI_Rewrite 2.x - NOT 3.x! You don't need to add anything by hand for 3.x as this version is 100% compatible with Apache and use the standard .htaccess files Drupal provides out of the box.

interestingaftermath’s picture

Ok, so I have undone all the settings that I added (settings.php and the .htaccess with ISAPI). What now? I try to enable clean urls through Drupal and it does not work.

I have ISAPI_Rewrite 3 installed on the server. What's next?

Sorry to be a pain.

hass’s picture

ISAPI_Rewrite 3.x:
D5 - Add $conf['clean_url'] = 1 to your settings.php - that's all you need to do.
D6 - do nothing extra - it simply works.

Us the latest version of ISAPI 3.x first :-). If this all does not help - enable LogLevel (http://www.helicontech.com/isapi_rewrite/doc/LogLevel.htm) setting and try to figure out what's wrong with ISAPI.

interestingaftermath’s picture

I added $conf['clean_url'] = 1 to my settings.php file but no luck. I guess that would have been too easy.

I added LogLevel debug to the .htaccess file via Helicon Config Editor but the log doesn't seem to read anything different. Am I doing something wrong?

interestingaftermath’s picture

After reading the Help info, I figured out where to put the LogLevel line.

It's saying it has insufficient access to the install directory of ISAPI_Rewrite and to the root directory of my site. I went through the permissions section in the Help file and it seems to all check out.

interestingaftermath’s picture

Sorry for the multiple posts but in reading, it seems like I need to give access to IIS_WPG but that group does not show up in my security tab. Any suggestions?

interestingaftermath’s picture

Last post of the evening:

I have figured out how to add IIS_WPG and then added the necessary permissions. My error.log is now blank and receives NO errors whatsoever. However, my links are still broken on my site. Any ideas?

I have added the conf string to settings.php and clean urls page shows ENABLED. When I click on a link, it tries to take me to the clean url page but the page is not found.

Thanks for everything.

interestingaftermath’s picture

GOT IT! For some reason when I moved my site the .htaccess file was not transferred. For anyone else having this same issue, here's where I found my answer:

http://www.helicontech.com/articles/drupal.htm

hass’s picture

I would say they have written this page after I informed them about ~10-15 releases that Drupal .htaccess is not working with ISAPI_Rewrite :-).

3.1.0.56 was the first that worked as it should. I know for sure you don't need to change the .htaccess file in Drupal's root as I'm also running this config and it works out of the box. But if IIS_WPG and NETWORK SERVICE don't have access to the .htaccess file you need to grant them permission - at least "change" on all dirs - otherwise this will never work.

Keep always in mind - Helicon say they provide nearly 100% Apache .htaccess compatibility and 100% of what Drupal use. As this is the case the standard file MUST work without any changes... if not - ISAPI_Rewrite have a bug - nevertheless they may try to tell you something different first... :-)

interestingaftermath’s picture

haas, you have been very helpful. Thank you! I have ONE last question, promise...

I am still using the trial of the FULL version. I am running a dedicated server where I host about 4 other sites that are NOT Drupal. I do not want to harm those sites whatsoever so I went with the FULL version. Is this necessary or could I get the LITE version and still do clean urls just for my one site? I know there is only 1 http.conf but because of version 3.x you clearly don't need to add anything to that file.

What do you think? Can I save my client $100 and still use this awesome software?

hass’s picture

Sorry, but I haven't tested with 3.x light version, but having all rules in one file (in the programs helicon directory) is proven to be non-administrable and time wasting and error prone and so on. You can disable ISAPI_Rewrite FULL by default for all sites and enable it only for specific sites... It's not the default setting, but we have also done this in past to not "harm" some sites. :-)

Give them the few bucks... their support is really good and bugs will be fixed very soon.

volkiz’s picture

rule imagecache folder before files folder like this:

RewriteRule ^/files/imagecache/(.*)$ /index.php\?q=/files/imagecache/$1 [I,L]
RewriteRule ^/files/(.*)$ /files/$1 [I,L]

bohz’s picture

I know this is an old post, but the rules posted by redamo still do work fine on IIS6 (thanks).
however, they do not work for sites installed in subdirectories.
I tried the rules posted in #25, but they do not work for IIRF.
Can anyone help me finding the correct rules for rewriting URLs in a subdirectory with IIRF on IIS6?
thanks a lot!

hass’s picture

With ISAPI 3.0 there is NO NEED to use the above rules. v3.0 use the standard Drupal .htaccess.

bohz’s picture

thank you.
but I am using Ionic Isapi Rewrite, not the Helicon filter.
However, i may switch to it; does the standard drupal .htaccess work with the lite 3.0 version?
thanks

nejine’s picture

bohz, can you give us some tip on how to use Ionic Isapi Rewrite for Drupal on IIS? It will shed us some light. Thank you.

bohz’s picture

HI!
Actually I am trying to understand that myself!
Anyway, I just followed the installation instructions and used the drupal ini file that is provided with the filter which, by the way, is exactly the one posted by redamo in #31.
Beside that, there's nothing special that I did to have IIRF working on IIS6.0 (Win server 2003).

Please note: at this time, I still cannot have IIRF working in subdirs, and there's another caveat: I have to disable the filter when running update.php (see http://drupal.org/node/348336).

I guess that, if ISAPI rewrite 3.0 LITE does work with subdirs, I will switch to it as soon as I can.
Hope this helps.
cheers

bohz’s picture

For completeness, and hoping it may help others, I have solved both problems thanks to this post on ServerFault.
To solve the problem with update.php, I simply replaced redamo's ini file with the one provided in the link above (not 100% sure that ALL the rules posted by redamo should be removed)

To have IIRF working in subdir AND in root folders I modified the rules as follows
(that is adding the rewriterule for the subfolder before the ones for the root without the 'L= Last test if match' flag):

# Do not pass to drupal if the file or directory exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Handle query strings on the end
# firstly for the subfolder without the L flag
RewriteRule /mysubfolder/(.*)\?(.*)$ /mysubfolder/index.php\?q=$1&$2 [I]
# then for the root
RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L]

# now pass through to the generic handler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# firstly for the subfolder without the L flag
RewriteRule ^/mysubfolder/(.*)$ /mysubfolder/index.php?q=$1 [I]
# then for the root
RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]

So far, it seems to work well.
Cheers

lias’s picture

Yes, that worked for me to using Ionics Isapi Rewrite Filter on Win2003 server, IIS 6 & PHP 5.3 with Drupal 7.15. What I had been missing was the Iirf.ini file copied to the website root directory.

Thanks to mparker17's post at http://serverfault.com/questions/13176/drupal-clean-url-on-iis

  1. Downloaded Ionic ISAPI Rewriting Filter 2.0.1.1013 (2.1) RELEASE and uncompressed the file
  2. Followed the instructions in the guide. The guide is included in the ZIP file at AdminGuide > Help > IirfGuide.chm. We used the IirfGlobal.ini file quoted at the end of this post.
  3. Restarted IIS
  4. Created an Iirf.ini file in the root folder of the site, entering only StatusUrl /iirsStatus RemoteOk. We then tested to see if IIRS was working by going to http://mysite.example.com/iirsStatus. It should print out some status lines for you.
  5. Changed the Iirf.ini file to it's final form, as quoted at the end of this post
  6. Turned on Clean URLs again. Don't turn on Global Redirect's "Non-clean to Clean" option though! It will redirect the page endlessly.

IirfGlobal.ini:

RewriteEngine ON
RewriteFilterPriority DEFAULT
NotifyLog OFF

Iirf.ini:

# Do not pass to drupal if the file or directory exists
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]

# Handle query strings on the end
RewriteRule /(.*)\?(.*)$ /index.php\?q=$1&$2 [I,L]

# now pass through to the generic handler
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/(.*)$ /index.php?q=$1 [I,L]