A simple guide to .htaccess
What is .htaccess
The .htaccess file is a simple text file (in ASCII format). In general you can use, .htaccess files to change some configuration directives of the apache web server. However, .htaccess files can do lot more than simply change some settings of your web server as you will find from the topics listed in this tutorial.
Please, note that the name of the file is “.htaccess”. It starts with a dot. By default on Unix/Linux systems files starting with a dot are not publicly visible. If you are running a Windows PC, it is likely that you will have troubles creating such a file. So if you need to create such a file, create it directly on your web hosting server and modify it there, using your FTP program, SSH or some web based file manager.
The .htaccess file can be placed on any folder on your site. It has recursive effect. This means that if you place the .htaccess file in your web root (the main folder of your web site) the directives and commands you place in the .htaccess file will have effect on all sub-folders.
If you place a .htaccess file in a sub-folder, its directives will override the ones that you have in your site main folder. That is if you disable directory listing globally for your site by placing the proper line in the .htaccess file in your main folder, you can then enable directory listing only for a particular sub-folder with another .htaccess file and the proper directive.
The commands and/or directives in a .htaccess file are placed one at a line.
You can comment a given line in a .htaccess file using the hash symbol “#”. For example:
When a line is commented it has no effect.
When somebody visits your site the Apache web server is checking if you have an .htaccess file somewhere in your web space starting from the root/main folder and traversing all the folders until it reaches the requested file. If an .htaccess file is found, its directives are applied to the current request.
It is important to know that the .htaccess file should be readable by the Apache server. So, please check with your host if they require any special permission set for .htaccess files. In general permissions of 644 should be working just fine.
- How to block users from accessing your site based on their IP address
- How to prevent or allow directory listing?
- How to change the error documents – 404 Page Not Found, etc
- Using .htaccess for password protecting your folders
- Using .htaccess to block referrer spam
- Disable Hot-Linking of images and other files
- Redirect URLs using .htaccess
- Introduction to mod_rewrite and some basic examples
- Force SSL/https using .htaccess and mod_rewrite
- 301 Permanent redirects for parked domain names
- Enable CGI, SSI with .htaccess
- How to add Mime-Types using .htaccess
- Change default directory page
- Block Bad robots, spiders, crawlers and harvesters
- Make PHP to work in your HTML files with .htacess
- Change PHP variables using .htaccess
- HTTP Authentication with PHP running as CGI/SuExec
- Force www vs non-www to avoid duplicate content on Google
- Duplicate content fix index.html vs / (slash only)
Comments 49 >>
How to use the configure the .htaccess file in my site..
Help me..!~!!!
what should i do? i have uploded all files in public_html directory.
can anyone help e plzzzzzzzzz
business models
Vijay
domain.com (all page in it) to
newdomain.com
Wait for your respons
If both domain names are pointed at the same server:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.newdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
if hosted on separate servers:
RewriteEngine On
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
This site is definitely bookmarked (^_^)
RewriteEngine on
RewriteBase /
RewriteRule (.*) index.php
You can forward all data to index.php
Thanks
Is there a way to make it visable in windows?
Windows does not recognise it.
So if there is a problem, it is not with the safari browser unless you have some rules that may affect safari browsers in some way.
I need to have both of these index files accessible by users...
index.html (this is an under construction splash page)
index.php (this is for accessing a Word Press site that's being created)
excellent information. But, (I know), what I was looking for seems to not be here.
I'm getting visitor spam from a linux operating system using safari v419.3 on my domains. floods of useless traffic (analytics shows direct traffic right after midnight aprox 400 visits) same geolocation...
How can i block linux operating system using safari in the htaccess file?
You can add multiple rules/commands into the .htaccess file. Just put each rule/command on a new line. For example:
ErrorDocument 404 "404 Not found"
Deny from 1.2.4.5
ErrorDocument 404 /error404.html
deny from 2.24.0.0/13
deny from 2.96.0.0/13
deny from 2.120.0.0/13
deny from 2.216.0.0/13
deny from 25.0.0.0/8
deny from 31.3.64.0/21
deny from 31.3.144.0/21
ErrorDocument 404 /error404.html
deny from 2.24.0.0/13
deny from 2.96.0.0/13
deny from 2.120.0.0/13
deny from 2.216.0.0/13
deny from 25.0.0.0/8
deny from 31.3.64.0/21
deny from 31.3.144.0/21
If you block your own IP, you will not get the 404 page at all as this is a missing page. When you block your IP you will get a Forbidden - 403 error.
I do not see a problem with the rules above they should work properly.
ErrorDocument 403 /error403.html
You can replace the error403.html with the name or path to your 403 error page.
| Previous: The effects of a Gated Internet on small business and the web hosting industry | Next: Overselling Tendency In The Hosting Market |
