Disable mod_rewrite for subdirectory

Oh, the strange things mod_rewrite does!

Disable mod_rewrite for subdirectory

Postby arne » Fri Oct 20, 2006 10:37 am

I'm the author of a Drupal - phpBB integration hack that relies heavily on mod_rewrite.

The problem is that there are two files:
/forum/login.php
/forum/admin/login.php

The requests for the first one need to be redirected to /login (Drupal), whereas requests for the second go to the administration interface and should not be rewritten.

My understanding is that mod_rewrite strips away the path if the rewrite rules are defined in .htaccess files. I normally don't use those, but lots of people do and I get their complaints.

Is there any other way to detect whether the request is for something in the admin-directory? I have tried using the requesturi environment variable and placing a .htaccess file that should disable mod_rewrite in the admin directory. I have also tried setting no rules, but keeping mod_rewrite enabled. None of those appear to work.

Any ideas?
arne
 
Posts: 3
Joined: Fri Oct 20, 2006 10:30 am

Postby richardk » Fri Oct 20, 2006 11:28 am

My understanding is that mod_rewrite strips away the path if the rewrite rules are defined in .htaccess files.

It only strips the path up to the dircetory the .htaccess file is in. So if the .htaccess file is located at /abc/.htaccess, it'll strip /abc/ from all URLs.

You could probably just add:
Code: Select all
RewriteCond %{REQUEST_URI} !^/forum/admin/login\.php$ [NC]


If you post the rule it can probably be done without a RewriteCond by editing the pattern.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby arne » Sat Oct 21, 2006 7:53 pm

I thought i had tested this, but I will try again as soon as I get a chance.
arne
 
Posts: 3
Joined: Fri Oct 20, 2006 10:30 am

Postby arne » Mon Oct 23, 2006 7:13 pm

The error was that phpBB suddenly switches to using POST rather than GET for the redirect-after-login commands, But your clear answer to the URL-stripping eliminated the necessary number of unknowns to find this.

Do any of the variables contain POST data? If not I'll just rely on HTTP_REFERER.

Thanks :)
arne
 
Posts: 3
Joined: Fri Oct 20, 2006 10:30 am

Postby richardk » Tue Oct 24, 2006 2:09 am

REQUEST_METHOD should contain GET or POST or whatever.

If you provide the rule i may be able to help more.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Idiosyncrasies

Who is online

Users browsing this forum: No registered users and 1 guest

cron