1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need help with .htaccess template

Discussion in 'Apache' started by purpler, May 1, 2010.

  1. #1
    I made an .htaccess template, is there anything else that should be added or changed for added benefit or security?

    
    # Defaults
    ServerSignature Off
    AddDefaultCharset UTF-8
    DefaultLanguage en-US
    SetEnv TZ Europe/Belgrade
    SetEnv SERVER_ADMIN admin@domain.tld
    
    # Rewrites
    Options +FollowSymLinks 
    RewriteEngine On
    RewriteBase /
    
    # Redirect to WWW
    RewriteCond %{HTTP_HOST} ^serpentineseo.com
    RewriteRule (.*) http://www.serpentineseo.com/$1 [R=301,L]
    
    #Redirect index to root
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.html\ HTTP/
    RewriteRule ^(.*)index\.html$ /$1 [R=301,L]
    
    # Cache media files:
    # Month
    <filesMatch "\.(gif|jpg|jpeg|png|ico|swf|js)$">
    Header set Cache-Control "max-age=2592000, public"
    </filesMatch>
    
    # Week
    <FilesMatch "\.(css|pdf)$">
    Header set Cache-Control "max-age=604800"
    </FilesMatch>
    
    # 10 Min
    <FilesMatch "\.(html|htm|txt)$">
    Header set Cache-Control "max-age=600"
    </FilesMatch>
    
    # Don't Cache
    <FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
    Header unset Cache-Control
    </FilesMatch>
    
    # Prevent hotlinking
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?serpentineseo.com/.*$ [NC]
    RewriteRule \.(gif|jpg)$ http://www.serpentineseo.com/images/angryman.png [R,L]
    
    # Error Documents
    ErrorDocument 206 /error/206.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 500 /error/500.html
    
    # Deny access to .htaccess
    <Files .htaccess>
    order allow,deny
    deny from all
    </Files>
    
    Code (markup):

     
    purpler, May 1, 2010 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    maybe just to prevent people from browsing your folders & files in folders where you don't have an index.html or default.html or whatever:

    
    Options -Indexes
    
    Code (markup):
     
    pr0t0n, May 1, 2010 IP
    purpler likes this.
  3. purpler

    purpler Peon

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    should i place .htaccess containing that code to every folder i want to restrict from being browsed or just put it in main on in website root?
     
    purpler, May 2, 2010 IP