+ Reply to Thread
Results 1 to 3 of 3

Thread: How to Protect Site from SQL Injections thrue .htaccess?

  1. #1
    Major Advisor
    Join Date
    Sep 2006
    Location
    India
    Posts
    204

    Default How to Protect Site from SQL Injections thrue .htaccess?

    if you have site then you will know about sql injections.

    here is small code to block unwanted sql injections
    PHP Code:
    RewriteCond %{QUERY_STRING} [^a-z](declare|char|set|cast|convert|delete|drop|exec|insert|meta|script|select|truncate|update)[^a-z] [NC]
    RewriteRule (.*) - [F
    put this code into .htaccess file

    so when hacker will insert this words into URL it will not post any value into database. and page will turn to 403 Error page.

    so only HTTP POST method will work to post value.

  2. #2
    Major Advisor roipatrick's Avatar
    Join Date
    Feb 2009
    Location
    Three stars and a sun
    Posts
    1,155

    Default Re: How to Protect Site from SQL Injections thrue .htaccess?

    just wanted to ask if this code will affect the whole code of sql?
    We help not because we need to but we help because we want to.........there's a big difference between "need" and "want"

  3. #3
    Major Advisor
    Join Date
    Sep 2006
    Location
    India
    Posts
    204

    Default Re: How to Protect Site from SQL Injections thrue .htaccess?

    Quote Originally Posted by roipatrick View Post
    just wanted to ask if this code will affect the whole code of sql?
    yes.

    i mean it will check query before submiting to database.

    so
    sitename.com/xyz.php?DECLARE @S CHAR(100); SET @S=CAST

    etc etc will not work.

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts