Hey Guys,
I am scarily new to .htaccess files but see the long term benefits from using it. I am pasting my .htaccess file which I have commented with the way I see what it does, but dont want to have items which is pointless or do not work on the long run for general sites. I created a php framework which I use for my sites and this is the .htaccess file I use. Please give comments, suggestions or ideas as I will really appreciate it
Please note that as with most frameworks, all of my request should be sent through a single portal (index.php)
# .htaccess file
# Follow all symbolic links (I'm not quite sure what this does :) )
Options +FollowSymLinks
# Turn the rewrite engine on
RewriteEngine On
# Turn the server signature off (speeds the site up a bit)
ServerSignature Off
# Protect against DOS attacks by limiting file upload size
LimitRequestBody 10240000
# Do not allow access to the .htaccess file
<Files .htaccess>
order allow,deny
deny from all
</Files>
# Set this for w3 validation and googlebot to crawl the site
Allow from w3.org htmlhelp.com
Allow from googlebot.com
Satisfy Any
#set the base Url (I really need help here. Does this set base to where my .htaccess file is located or to my webroot (lets say my project was located under domain.com/project/.htaccess) - Is my rewritebase the project/ folder or the domain.com/ folder?)
RewriteBase sites/opanel.co.za
# Ensure all URL's is processed using the www.
RewriteCond %{HTTP_HOST} !^www\\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#dont send the apache error document, but rather send the not found to index.php
ErrorDocument 404 index.php
# Send a forbidden request to some known web spiders
RewriteCond %{HTTP_USER_AGENT} ^Anarchie [OR]
RewriteCond %{HTTP_USER_AGENT} ^ASPSeek [OR]
RewriteCond %{HTTP_USER_AGENT} ^attach [OR]
RewriteCond %{HTTP_USER_AGENT} ^autoemailspider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xaldon\\ WebSpider [OR]
RewriteCond %{HTTP_USER_AGENT} ^Xenu [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus.*Webster [OR]
RewriteCond %{HTTP_USER_AGENT} ^Zeus
RewriteRule ^.* - [F,L]
# Disable directory / folder listings and access
Options All -Indexes
IndexIgnore *
# Redirecting index.php to root
RewriteCond %{THE_REQUEST} ^.*/index\\.php
RewriteRule ^(.*)index\\.php$ /$1 [L,R=301]
# Send all requests to the index.php file
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !^/robots\\.txt$
RewriteRule ^ index.php [L]