htaccess problem... how do I create an exception to a rewrite rule?

Discussion in 'Apache' started by helgatheviking, Sep 27, 2009.

  1. #1
    I am trying to rewrite any url that is a 4 character string and send that to my supr.php script (a stumbleupon application) which handles the redirects for shorturls on my own domain.

    i want mysite.com/2c4h (or any random string of 4 characters) to go to the script. This part works just fine. However, I realized that this was also including my /feed directory, which is not so fine.

    Here is the original rule:

    RewriteRule ^[a-zA-Z0-9]{4}$ supr.php?supr=$0

    and here is what I tried.

    RewriteRule (^[a-zA-Z0-9]{4}$)(?<!feed) supr.php?supr=$0

    I grabbed this from someone else who supposedly solved the same problem with this rewrite rule BUT, my server creates creates a 500 Internal Server Error with this and the error log says it is because it cannot parse this line.

    soooo? I am lost and have tried about everything I can think to try. Hopefully someone here who is far more knowledgeable with this can help?

    Thanks in advance,
    -Helga
     
    helgatheviking, Sep 27, 2009 IP
  2. chadsmith

    chadsmith Peon

    Messages:
    82
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can put a rule for feed directly in front of it and use [L] to tell it to stop processing. For example:

    RewriteRule ^feed - [L]
    Code (markup):
     
    chadsmith, Sep 27, 2009 IP
  3. helgatheviking

    helgatheviking Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you, sir, are a genius! i never would have thought of a separate rule. I tried what you posted and it stopped me from getting to some other needed rules that came after. So I tried rearranging the order, but that broke some things. Then I looked back at what flags were available and found the skip x number of rules flag instead... and everything is working!

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteRule ^feed - [S=3]
    RewriteRule ^[a-zA-Z0-9]{4}$ supr.php?supr=$0
    RewriteRule ^check_supr_install$ ?check_install=$0
    RewriteRule ^supr_settings.json$ ?supr_settings_json=$0

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Thank you so much. I had been at my wit's end here!

    Sending you my best wishes and all the positive energy I can muster.

    -Helga
     
    helgatheviking, Sep 27, 2009 IP