.htaccess

Discussion in 'Apache' started by Dehisce, Oct 14, 2007.

  1. #1
    I have been playing around with this for hours but can't get it right.

    How do I get from this:
    domain.com/folder

    To this:
    domains.com/forward.php?i=folder

    I get it working, but it then tries redirecting all my php pages to forward.php too. Is there a way to say don't attempt to forward pages.
     
    Dehisce, Oct 14, 2007 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    My guess is that you have something like this:

    RewriteRule (.*) forward.php?i=$1
    Code (markup):
    But you need something more restrictive. There are two things that can help you here, firstly anchor the regex and make the character class less accepting.
    
    RewriteRule ^([a-zA-Z0-9]+)$ forward.php?i=$1
    Code (markup):
    ...and secondly, use a RewriteCond to make sure you aren't rewriting away from a real file. Put this just before the RewriteRule.

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-l
    Code (markup):
    Either one of these will probably solve your problem. If this still doesn't work, post your current rewrite rules and some example folder names.

    My post on Apache Regular expressions might also be of some help.
     
    Ladadadada, Oct 14, 2007 IP
  3. Dehisce

    Dehisce Peon

    Messages:
    234
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you !
     
    Dehisce, Oct 15, 2007 IP