Block access to your .htaccess file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Block access to your .htaccess file

    The following code will prevent user to access your .htaccess file. Also, you can block multiple file type as well.

    # secure htaccess file
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>

    # prevent viewing of a specific file
    <Files secretfile.jpg>
    order allow,deny
    deny from all
    </Files>

    # multiple file types
    <FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
    Order Allow,Deny
    Deny from all
    </FilesMatch>

    #2
    this code insert on the .htaccess ???

    Comment


      #3
      yes its on the .htaccess

      Comment


        #4
        razzbe bro do u know .htaccess code that user can redirect ... url
        mysite.com/username ++> mysite.com/index.php?user=username

        Comment


          #5
          Search for mod-rewrite, its solved hundreds times for pages and for users.
          <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

          Comment


            #6
            Options +FollowSymlinks
            RewriteEngine On
            RewriteRule ^([a-zA-Z0-9_$\-]+)$ index.php?user=$1

            Comment


              #7
              Originally posted by razzbee View Post
              The following code will prevent user to access your .htaccess file. Also, you can block multiple file type as well.

              # secure htaccess file
              <Files .htaccess>
              order allow,deny
              deny from all
              </Files>

              # prevent viewing of a specific file
              <Files secretfile.jpg>
              order allow,deny
              deny from all
              </Files>

              # multiple file types
              <FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
              Order Allow,Deny
              Deny from all
              </FilesMatch>
              if already have this one:
              <FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
              Order Allow,Deny
              Deny from all
              </FilesMatch>


              this one is not necessary:
              <Files .htaccess>
              order allow,deny
              deny from all
              </Files>

              Comment


                #8
                Originally posted by ogah View Post
                if already have this one:
                <FilesMatch ".(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$ ">
                Order Allow,Deny
                Deny from all
                </FilesMatch>


                this one is not necessary:
                <Files .htaccess>
                order allow,deny
                deny from all
                </Files>
                FilesMatch uses Regex so its recommended U use the correct and recommended code even though that will work but escape the dot (.)
                the dot must be \.
                so do this :
                Code:
                <FilesMatch "\.(htaccess|htpasswd|ini|phps|fla|psd|log|sh)$">
                 Order Allow,Deny
                 Deny from all
                </FilesMatch>

                Comment

                Working...
                X