[documentation] [Documentation task] Impossible to use Windows IIS/ISAPI Rewrite with new Clean URL check

RobRoy drupal-docs at drupal.org
Tue Jan 23 19:19:30 UTC 2007


Issue status update for 
http://drupal.org/node/61367
Post a follow up: 
http://drupal.org/project/comments/add/61367

-Project:      Drupal
+Project:      Documentation
-Version:      4.7.0
+Version:      <none>
-Component:    system.module
+Component:    Admin Guide
-Category:     bug reports
+Category:     tasks
 Priority:     normal
-Assigned to:  Anonymous
+Assigned to:  RobRoy
 Reported by:  brashquido
 Updated by:   RobRoy
-Status:       by design
+Status:       fixed

Fixed that handbook page. Look okay?




RobRoy



Previous comments:
------------------------------------------------------------------------

Tue, 02 May 2006 05:59:20 +0000 : brashquido

Attachment: http://drupal.org/files/issues/system.module (57.38 KB)

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.




------------------------------------------------------------------------

Tue, 02 May 2006 08:08:38 +0000 : chx

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




------------------------------------------------------------------------

Tue, 02 May 2006 12:18:12 +0000 : brashquido

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.




------------------------------------------------------------------------

Tue, 02 May 2006 16:58:43 +0000 : sepeck

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




------------------------------------------------------------------------

Wed, 03 May 2006 01:19:40 +0000 : brashquido

Sorry, my mistake; 


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


Cheers




------------------------------------------------------------------------

Fri, 15 Sep 2006 16:13:32 +0000 : magico

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.




------------------------------------------------------------------------

Sat, 20 Jan 2007 20:28:26 +0000 : MikeOConnor

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.  :-)




------------------------------------------------------------------------

Sun, 21 Jan 2007 13:30:06 +0000 : NorthernLightsSpain

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.




------------------------------------------------------------------------

Tue, 23 Jan 2007 18:40:58 +0000 : hass

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






More information about the documentation mailing list