need mod_rewrite rule

Discussion in 'Apache' started by kailash, Oct 6, 2007.

  1. #1
    Hi,

    I need the rewrite rule to disable the browsing site like below:

    http:*//domain.com/abc.php?c=http://otherdomain.com/abc.txt? (* is used to disable active link)

    Can anybody provide me the such rule which I can write in .htaccess file so that if anyone browse the website like above, they will get 403 forbidden error.

    Thanks,

    Kailash
     
    kailash, Oct 6, 2007 IP
  2. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #2
    RewriteRule ^/?abc.php\?.*c=https?://otherdomain.com/abc.txt - [F,L]

    Although someone could still get around this... by URL encoding the parameters passed to your script.

    The most robust way would be to do this in PHP. Validate the URL and if it's not valid, you can send a custom 403 page with:
    header("403 Forbidden");
    echo("You are not allowed to view pages from otherdomain.com using this script.");
    PHP:
     
    Ladadadada, Oct 7, 2007 IP