mod_rewrite - NOT (foo OR bar)

Discussion in 'Apache' started by mattmorten, Dec 7, 2006.

  1. #1
    Hey all,

    I want to use the mod_rewrite to allow any URL *except*:

    http://localhost/foo/
    http://localhost/bar/

    ie, this would be allowed:

    http://localhost/hello_world/

    The rule I have used is a little complictated. I think it is correct because I've used a regexp test applet and it comes up fine:

    RewriteRule ^((?!foo|bar).)*/$ /home/main.htm

    I'm getting a 500 Internal Server error. I can't think what is wrong. Any ideas?

    Many thanks,
    Matt
     
    mattmorten, Dec 7, 2006 IP
  2. IntelliGuy

    IntelliGuy Banned

    Messages:
    42
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This code will redirect urls that start with /foo or /bar to /home/main.htm

    RewriteEngine   On
    
    RewriteRule   ^/(foo|bar)(/.*)?$   /home/main.htm   [L]
    Code (markup):
     
    IntelliGuy, Dec 9, 2006 IP