By choosing various options and describing the generated text in .htaccess file, you can quickly create .htaccess file.
You can also generate hashed passwords for Basic authentication (.htpasswd).
What is .htaccess file?
A setup file to manage HTTP server like Apache.
Settings such as basic authentication, redirection, and error page can be set for each directory.
What is .htpasswd file?
It is used to protect files, folders, or entire websites using HTTP user authentication called BASIC authentication, and is implemented based on the rules described in the .htaccess file.
User information is written on one line per user, and each line contains a username and password separated by a colon (:). Usernames are stored in plain text, but passwords are stored in hashed form.
You can give the password file any name, but since Apache uses .htpasswd by default and dot files (files starting with '.') become usually hidden files, it is recommended to name a file as '.htpasswd'.
Frequently used settings of .htaccess files :
- Rewrite non-www to www/ Remove www from URL
- Redirect http/ https
- Redirect to file or directory
- Setting Basic authentication
- Hotlink prevention setting
- Custom Error Pages (400, 404, 500, etc) setting
- Block or Allow IPs
- Block bots
- Change default directory page
- Rejecting access to . (dot)
- Prevent directory listing
- Enable gzip
Rules with .htaccess file
- .htaccess file works with the current directory and all of its subfolders.
- If the .htaccess file fails to run, a 500 error is returned to the client. So please be careful when editing it. Before editing, it is recommended to make a copy as a backup.
- Use “#” before a line you don’t want to run to switch the line to comment mode.