# What is htaccess and How to Use It?

https://bihostnet.com/en/knowledgebase/article/htaccess-guide-redirects-security

## Force HTTPS

```
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
```

## Disable Directory Listing

```
Options -Indexes
```

## Custom Error Pages

```
ErrorDocument 404 /404.html
ErrorDocument 500 /500.html
```

## Protect wp-config.php

```
<Files wp-config.php>
Order Allow,Deny
Deny from all
</Files>
```
