Forum Moderators: phranque

Message Too Old, No Replies

rewriterules not being obeyed?

question about the priority of rewrite rules

         

clinch

4:04 pm on Jul 20, 2011 (gmt 0)

10+ Year Member



I have the following:


Options -Indexes
Options +FollowSymLinks
DirectoryIndex /drupal/index.php

RewriteEngine On

RewriteRule ^django - [L,QSA]
RewriteRule ^ncc1701 - [L,QSA]
RewriteRule ^(sites/.*)$ drupal/$1 [L,QSA]
RewriteRule ^(.*)$ /drupal/index.php?q=$1 [QSA]


I am trying to make calls to /django untouched. I would expect that from the first RewriteRule, but it seems that calls to /django/blahblah are still being rewritten by the last rule /drupal/index.php?q=$1. I thought the L flag on the first RewriteRule would just skip the rest of the rules? Are not the rules processed in the order I give them?

Edit: I have tried it with /?django.

clinch

4:30 pm on Jul 20, 2011 (gmt 0)

10+ Year Member



Never mind. I found out that the problem was in another .htaccess file. Tricky.

lucy24

7:00 pm on Jul 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I thought the L flag on the first RewriteRule would just skip the rest of the rules? Are not the rules processed in the order I give them?

Yes, within mod_rewrite and within the current pass through .htaccess. But the [L] does not mean "stop here, proceed directly to the page, and never set foot in this .htaccess file again". It means "stop here, go back to the beginning and see if any fresh rules apply now that you've applied this one". There is no über-flag that says "under no circumstances are you to look at this request ever again".

g1smd

7:16 pm on Jul 20, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You only need QSA on the final rule.

It is the default on the other three rules so does not need to be stated, but will be totally ignored on the first two.

clinch

7:51 pm on Jul 20, 2011 (gmt 0)

10+ Year Member



Ah. Thank you guys for the clarifications!