.htaccessToday our topic is very important for web developers about the htaccess file, often you find it inside a script folder or hosting site, but have you ever wonder what the purpose of this file is ?
What is the htaccess file?
.htaccess is a plain text file. The file name comes from hypertext access, a configuration file supported by a number of web servers and used to control server settings in a decentralized way. It is placed within the file tree and is capable of overriding the secondary server settings of the folder in it and its contents of files and subfolders. And the .htaccess file is one of the most important files on which the Web sites rely on the Apache HTTP Server servers.
How do I create an .htaccess file. ?
You can easily create a htaccess file from a plain text editor that opens the editor and then saves the file under the .htaccess name
If you are a Windows user which will prevent you from creating the file, the solution is to save the file under the name of htaccess.txt. When you upload it to your host, rename it to "htaccess." It is recommended that you create it in the main folder to host you directly.
What are its uses?
- Protect the site folders with a user name and password.
- Redirect from one page to another.
- Clean links by RewriteRule.
- Define the host server with SSI commands that you design for your site
- Protect the bandwidth in the site from external consumption both in files and images.
- Block the site from visitors from a particular country or make it to visitors of a particular country or block it from a specific IP.
- Hide folder contents for members or a specific type of file only in the folder.
- Make error pages.
Some commands are htaccess file. ?
1. Set the index file to the main index of the site:
2. Change the original name of your pages:
RewriteRule ^ new-page.html $ page.php
3. Prevent a specific IP from accessing your site:
denied from 000,000,000,000
Change the 000,000,000,000 to the ip you want to prevent from accessing your site.
4. Set error pages:
ErrorDocument 401 /err/401.php
ErrorDocument 403 /err/403.php
ErrorDocument 404 /err/404.php
ErrorDocument 500 /err/500.php
5. Redirecting HTaccess 301:
Redirect 301 / old-webpage http://www.yourblog.com/new-webpage
6. Set charset to htaccess:
AddCharset UTF-8 .html
Do not forget to share your opinion in the comments section and also join us on the social networking sites to stay connected with us.
Post a Comment