Skip to content
ADMAX
Web hosting

.htaccess

Since 1996Swedish supportServers in Sweden
Back to the knowledge base

.htaccess is a configuration file that can be used for many different purposes. Below are some examples of what it can do.

  • Error pages
  • Redirects, sending visitors to a specific page
  • Password protection
  • Blocking IP addresses

Below is an example of code to redirect visitors from one page to another.

Options +FollowSymLinks
RewriteEngine On
Redirect 301 /gammalkatalog https://mittfinaforetag/nykatalog/

When a visitor goes to https://mittfinaforetag.se/gammalkatalog/, they will automatically be redirected to https://mittfinaforetag/nykatalog/.

Below is an example of code to password-protect a website:

The .htaccess file:
AuthType Basic
AuthName "Password Protected Area"
AuthUserFile /passwordlocation/.htpasswd
Require valid-user

The .htpasswd file:
username:YOuR123!Pa5SW0rD361!