.httaccess file
.htaccess is a configuration file for use on web servers running the Apache Web Server software. When a .htaccess file is placed in a directory which is in turn 'loaded via the Apache Web Server', then the .htaccess file is detected and executed by the Apache Web Server software. These .htaccess files can be used to alter the configuration of the Apache Web Server software to enable/disable additional functionality and features that the Apache Web Server software has to offer
Create .httaccess file
How to create a .httaccess file. Create a file and rename it to .httaccess file without any name. Only have the extension .httaccess . Sometimes you have problems to create .httacces file. So first create a file and rename it something.httaccess file. Now save with .httaccess file. After saving rename it to .httaccess without any name.
After compltet creating the .httaccess file ipload your server in root folder so that your uploaded url be ...
If your site domain is http://www.mydomain.com, then the files location will be
http://www.mydomain.com/.httaccess
After compltet creating the .httaccess file ipload your server in root folder so that your uploaded url be ...
If your site domain is http://www.mydomain.com, then the files location will be
http://www.mydomain.com/.httaccess
What do the .httaccess file
.httaccess file do some major works for maintaing your server configuration. The working lists are
01. Custom error pages
02. Enabling SSI via htaccess
03. deny / allow users by IP
04. Change default directory page
05. Block users by referrer
06. Block bad bots and site rippers
07. Redirect url
08. Prevent viewing of htaccess
09. Password protection
10. Adding MIME types
11. Prevent hot linking links and files
12. Prevent directory listing
01. Custom error pages
02. Enabling SSI via htaccess
03. deny / allow users by IP
04. Change default directory page
05. Block users by referrer
06. Block bad bots and site rippers
07. Redirect url
08. Prevent viewing of htaccess
09. Password protection
10. Adding MIME types
11. Prevent hot linking links and files
12. Prevent directory listing
01 Custom error pages
Sometimes we found some problem when browsing webpages. Some of this errors are
401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page
These are very useful and allow you to specify a page that the user goes to if there is an error. The most useful way you could use this is with the "404 Page Not Found" error. You can provide the user a list of common links, a link to your homepage, an e-mail address or whatever you feel like!
You can write this in this way
ErrorDocument code /filename.ext
ErrorDocument code /directory/filename.ext
401 - Authorization Required
400 - Bad request
403 - Forbidden
500 - Internal Server Error
404 - Wrong page
These are very useful and allow you to specify a page that the user goes to if there is an error. The most useful way you could use this is with the "404 Page Not Found" error. You can provide the user a list of common links, a link to your homepage, an e-mail address or whatever you feel like!
You can write this in this way
ErrorDocument code /filename.ext
ErrorDocument code /directory/filename.ext
ErrorDocument 400 /errors/bad-request.html ErrorDocument 401 /errors/auth-required.html ErrorDocument 403 /errors/forbid.html ErrorDocument 404 /errors/not-found.html ErrorDocument 500 /errors/server-error.html ErrorDocument 401 "<body bgcolor=#ffffff><h1>You have to actually <b>BE</b> a <a href="#">member</A> to view this page, Colonel!
02 Enabling SSI via htaccess
Many people want to use SSI, but don't seem to have the ability to do so with their current web host. You can change that with htaccess
The first line tells the server that pages with a .shtml extension (for Server parsed HTML) are valid. The second line adds a handler, the actual SSI bit, in all files named .shtml. This tells the server that any file named .shtml should be parsed for server side commands. The last line is just techno-junk that you should throw in there.
The first line tells the server that pages with a .shtml extension (for Server parsed HTML) are valid. The second line adds a handler, the actual SSI bit, in all files named .shtml. This tells the server that any file named .shtml should be parsed for server side commands. The last line is just techno-junk that you should throw in there.
AddType text/html .shtml AddHandler server-parsed .html AddHandler server-parsed .shtml Options Indexes FollowSymLinks Includes
03 Deny/Allow Certian IP Addresses
Your site can allow and delay certain ip adress.
deny from 000.000.000.000 allow from 000.000.000.000 deny from all //allow only one ip address <Limit GET POST PUT> order deny,allow deny from all allow from 12.345.67.890 </Limit> //allow only one ip address <Limit GET POST PUT> order deny,allow deny from all allow from 12.345.67.890 allow from 890.67.345.12 </Limit> //deny only multiple ip address order allow,deny deny from 123.45.6.7 deny from 012.34.5. allow from all
04 change default Index Files
In your directory the DirecoryIndex file is preventing thedirectry listing.When you enter your directory the DirectoryIndex file is automatically open. So you nned to use DirectoryIndex file. And you can use your own DirentoryIndex file which you locate
DirectoryIndex index.php index.php3 messagebrd.pl index.html index.htm DirectoryIndex taslim.php taslim.html taslim.js taslim.htm
05 Deny users by referrer
To block reffere site you must read these code. Here domainname is the site name of domainname.com nad NC means not Case Sensitive. If you block multiple referrer you use OR after NC and seperated by comma
//syntax RewriteEngine on # Options +FollowSymlinks RewriteCond %{HTTP_REFERER} badsite\.com [NC] RewriteRule .* - [F] //block domainame.com RewriteEngine on # Options +FollowSymlinks RewriteCond %{HTTP_REFERER} domainname\.com [NC] RewriteRule .* - [F] //block domainname.com and anotherdomainname.com RewriteEngine on # Options +FollowSymlinks RewriteCond %{HTTP_REFERER} domainname\.com [NC,OR] RewriteCond %{HTTP_REFERER} anotherdomainname\.com RewriteRule .* - [F] //deny using your sites images ( your site name : mydomain.com and file type is gif and jpeg). //You can change domain and file extensions RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC] RewriteRule \.(gif|jpg)$ - [F]
06 Block bad bots and site rippers (offline browsers)
Sometimes many user want to download your whole site and browse ofline. This is good but i any user downloaded all the contents next tie this user does not need to browse your site. So that your sites user decrease and your site looses its ranking.
RewriteEngine On RewriteCond %{HTTP_USER_AGENT} ^BlackWidow [OR] RewriteCond %{HTTP_USER_AGENT} ^Bot\ mailto:craftbot@yahoo.com [OR] RewriteCond %{HTTP_USER_AGENT} ^ChinaClaw [OR] RewriteCond %{HTTP_USER_AGENT} ^Custo [OR] RewriteCond %{HTTP_USER_AGENT} ^DISCo [OR] RewriteCond %{HTTP_USER_AGENT} ^Download\ Demon [OR] RewriteCond %{HTTP_USER_AGENT} ^eCatch [OR] RewriteCond %{HTTP_USER_AGENT} ^EirGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR] RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR] RewriteCond %{HTTP_USER_AGENT} ^Express\ WebPictures [OR] RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR] RewriteCond %{HTTP_USER_AGENT} ^EyeNetIE [OR] RewriteCond %{HTTP_USER_AGENT} ^FlashGet [OR] RewriteCond %{HTTP_USER_AGENT} ^GetRight [OR] RewriteCond %{HTTP_USER_AGENT} ^GetWeb! [OR] RewriteCond %{HTTP_USER_AGENT} ^Go!Zilla [OR] RewriteCond %{HTTP_USER_AGENT} ^Go-Ahead-Got-It [OR] RewriteCond %{HTTP_USER_AGENT} ^GrabNet [OR] RewriteCond %{HTTP_USER_AGENT} ^Grafula [OR] RewriteCond %{HTTP_USER_AGENT} ^HMView [OR] RewriteCond %{HTTP_USER_AGENT} HTTrack [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^Image\ Stripper [OR] RewriteCond %{HTTP_USER_AGENT} ^Image\ Sucker [OR] RewriteCond %{HTTP_USER_AGENT} Indy\ Library [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^InterGET [OR] RewriteCond %{HTTP_USER_AGENT} ^Internet\ Ninja [OR] RewriteCond %{HTTP_USER_AGENT} ^JetCar [OR] RewriteCond %{HTTP_USER_AGENT} ^JOC\ Web\ Spider [OR] RewriteCond %{HTTP_USER_AGENT} ^larbin [OR] RewriteCond %{HTTP_USER_AGENT} ^LeechFTP [OR] RewriteCond %{HTTP_USER_AGENT} ^Mass\ Downloader [OR] RewriteCond %{HTTP_USER_AGENT} ^MIDown\ tool [OR] RewriteCond %{HTTP_USER_AGENT} ^Mister\ PiX [OR] RewriteCond %{HTTP_USER_AGENT} ^Navroad [OR] RewriteCond %{HTTP_USER_AGENT} ^NearSite [OR] RewriteCond %{HTTP_USER_AGENT} ^NetAnts [OR] RewriteCond %{HTTP_USER_AGENT} ^NetSpider [OR] RewriteCond %{HTTP_USER_AGENT} ^Net\ Vampire [OR] RewriteCond %{HTTP_USER_AGENT} ^NetZIP [OR] RewriteCond %{HTTP_USER_AGENT} ^Octopus [OR] RewriteCond %{HTTP_USER_AGENT} ^Offline\ Explorer [OR] RewriteCond %{HTTP_USER_AGENT} ^Offline\ Navigator [OR] RewriteCond %{HTTP_USER_AGENT} ^PageGrabber [OR] RewriteCond %{HTTP_USER_AGENT} ^Papa\ Foto [OR] RewriteCond %{HTTP_USER_AGENT} ^pavuk [OR] RewriteCond %{HTTP_USER_AGENT} ^pcBrowser [OR] RewriteCond %{HTTP_USER_AGENT} ^RealDownload [OR] RewriteCond %{HTTP_USER_AGENT} ^ReGet [OR] RewriteCond %{HTTP_USER_AGENT} ^SiteSnagger [OR] RewriteCond %{HTTP_USER_AGENT} ^SmartDownload [OR] RewriteCond %{HTTP_USER_AGENT} ^SuperBot [OR] RewriteCond %{HTTP_USER_AGENT} ^SuperHTTP [OR] RewriteCond %{HTTP_USER_AGENT} ^Surfbot [OR] RewriteCond %{HTTP_USER_AGENT} ^tAkeOut [OR] RewriteCond %{HTTP_USER_AGENT} ^Teleport\ Pro [OR] RewriteCond %{HTTP_USER_AGENT} ^VoidEYE [OR] RewriteCond %{HTTP_USER_AGENT} ^Web\ Image\ Collector [OR] RewriteCond %{HTTP_USER_AGENT} ^Web\ Sucker [OR] RewriteCond %{HTTP_USER_AGENT} ^WebAuto [OR] RewriteCond %{HTTP_USER_AGENT} ^WebCopier [OR] RewriteCond %{HTTP_USER_AGENT} ^WebFetch [OR] RewriteCond %{HTTP_USER_AGENT} ^WebGo\ IS [OR] RewriteCond %{HTTP_USER_AGENT} ^WebLeacher [OR] RewriteCond %{HTTP_USER_AGENT} ^WebReaper [OR] RewriteCond %{HTTP_USER_AGENT} ^WebSauger [OR] RewriteCond %{HTTP_USER_AGENT} ^Website\ eXtractor [OR] RewriteCond %{HTTP_USER_AGENT} ^Website\ Quester [OR] RewriteCond %{HTTP_USER_AGENT} ^WebStripper [OR] RewriteCond %{HTTP_USER_AGENT} ^WebWhacker [OR] RewriteCond %{HTTP_USER_AGENT} ^WebZIP [OR] RewriteCond %{HTTP_USER_AGENT} ^Wget [OR] RewriteCond %{HTTP_USER_AGENT} ^Widow [OR] RewriteCond %{HTTP_USER_AGENT} ^WWWOFFLE [OR] RewriteCond %{HTTP_USER_AGENT} ^Xaldon\ WebSpider [OR] RewriteCond %{HTTP_USER_AGENT} ^Zeus RewriteRule ^.* - [F,L]
07 Redirect url
If you want to redirect any page from old location to new location you can use this code
Redirect /location/from/root/file.ext http://www.othersite.com/new/file/location.xyz
08 Prevent .httaccess file view
Prevent to view the .httacces file
<Files .htaccess> order allow,deny deny from all </Files>
09 password protection
AuthUserFile /usr/local/you/safedir/.htpasswd AuthGroupFile /dev/null AuthName EnterPassword AuthType Basic require user tajbir
password protection
Create a .htpasswd file without any name like the .httacess file. And save this code
username:password tajbir:tajpass
10 Adding MIME types
What if your server wasn't set up to deliver certain file types properly? A common occurrence with MP3 or even SWF files.
AddType is specifying that you are adding a MIME type. The application string is the actual parameter of the MIME you are adding, and the final little bit is the default extension for the MIME type you just added, in our example this is swf for ShockWave File.
AddType application/x-shockwave-flash swf
11 link prventation
Hot link prevention refers to stopping web sites that are not your own from displaying your files or content, e.g. stopping visitors from other web sites. This is most commonly used to prevent other web sites from displaying your images but it can be used to prevent people using your JavaScript or CSS (cascading style sheet) files. The problem with hot linking is it uses your bandwidth, which in turn costs money, hot linking is often referred to as 'bandwidth theft'.
RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC] RewriteRule \.(gif|jpg|css)$ - [F] RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?yourdomain.com/.*$ [NC] RewriteRule \.(gif|jpg)$ http://www.yourdomain.com/hotlink.jpg [R,L]
12 Stop A Directory Index
If your site has some directory and there is no DirectoryIndex files {like index.php, index.html etc} in the directory, then the server ruturns the list of files in this directory.
To prevent directory listing type this code
To prevent directory listing type this code
IndexIgnore * //stop indexing all files IndexIgnore *.gif *.jpg //stop indexing gif and jpeg files Options -Indexes //stop indexing directory
No comments:
Post a Comment