Forbid Rule If Everything Fails

Discussion in 'Apache' started by kruc3fix, Sep 3, 2007.

  1. #1
    Hi,

    This is my first post in this forum and I would like to say HI to everyone!

    I have this sandbox site http://www.bootsnall.com/frame/

    HTTP login -
    user: frame
    password: 12

    .. and basicaly all my links are like this:
    http:/www.bootsnall.com/frame/index.php?frame_action=module/action

    Placing a mod_rewrite rule like this one:
    RewriteRule ^(.*)$ /frame/web/index.php?frame_action=$1 [QSA,L]
    will actualy change all my links to:
    http:/www.bootsnall.com/frame/login.html

    The question is: How do I forbid people from going to "index(.*)" pages ?
    http:/www.bootsnall.com/frame/index.html
    http:/www.bootsnall.com/frame/index.php
    http:/www.bootsnall.com/frame/index.php?frame_action=module/action
    http:/www.bootsnall.com/frame/index.php?haxxxx=true
    .. etc....

    I want the main page to only be accesible by going to
    http:/www.bootsnall.com/frame
    and not
    http:/www.bootsnall.com/frame/index.html
    or other variants and also I want people to use
    http:/www.bootsnall.com/frame/page.html
    and not
    http:/www.bootsnall.com/frame/index.php?frame_action=module/page

    A possible solution: - Can I do the following?
    main rule: RewriteRule ^(.*)$ /frame/web/index.php?frame_action=$1 [QSA,L] [.. some end flag that will not let the next rule to be triggered ..]
    second rule: [.. If the above rule does not apply than follow this rule ..]
     
    kruc3fix, Sep 3, 2007 IP
  2. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #2
    Welcome to DigitalPoint!

    I think you could use the Skip flag to do that, [S=1] for example.

    But I'm not sure if it's even needed until I have a look at your current .htaccess.
     
    VimF, Sep 3, 2007 IP
  3. kruc3fix

    kruc3fix Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    main directory

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^$ /frame/web/ [L]
    RewriteRule (.*) /frame/web/$1 [L]
    </IfModule>

    main/web directory

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^images/captcha.jpg /frame/images/captcha.php [L]
    RewriteRule ^javascript/action_(.*).js /frame/javascript/action.php?action=$1 [L]
    RewriteRule ^uploads/image_(.*) /frame/uploads/image.php?src=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ /frame/web/index.php?frame_action=$1 [QSA,L]
    </IfModule>
     
    kruc3fix, Sep 4, 2007 IP
  4. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #4
    RewriteEngine On
    RewriteBase /
    RewriteRule ^images/captcha.jpg /frame/images/captcha.php [L]
    RewriteRule ^javascript/action_(.*).js /frame/javascript/action.php?action=$1 [L]
    RewriteRule ^uploads/image_(.*) /frame/uploads/image.php?src=$1 [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ /frame/web/index.php?frame_action=$1 [QSA,L]
    RewriteCond %{THE_REQUEST} index\. [NC]
    RewriteRule . /frame/web/ [L,R=301]
     
    VimF, Sep 4, 2007 IP