0π
In the end, after looking through the docs, I was not able to understand how to set it up. I found this page, and using option #2 I was able to get the directory to at least show up.
I then added the auth to the folder through the .htaccess
file and added the .htpasswd
file with the username/password combo
TLDR
- Create the folder in the location you want. In my case it was in
httpdocs/documents
- Create a
.htaccess
file where you put the following contents:
# Omit this section if you do not need the auth
AuthType Basic
AuthName "restricted area"
AuthUserFile /path/to/your/.htpasswd
require valid-user
Order allow,deny
Allow from all
Options +Indexes
- Create the
.htpasswd
file in the location you specified above. To generate the username/password combo I used this
Any corrections are welcome!
0π
You can have multiple rewrite rules based on what the RewriteBase
is . In your current set, the rule is applying to the root of the host.
You can add another rule with RewriteBase /documents/
. More info: What does RewriteBase do and how to use it?
0π
I recommend reading the docs: https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html
The RewriteCond directive defines a rule condition.
So here a dirty explanation:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
So your RewriteConds says that if the given path/url isnβt a file (!-f) and not a directory (!-d) then the next rewrite rule (RewriteRule . /index.html [L]) takes action.
RewriteRule . /index.html [L]
β.β is a wildcard, so all urls will be redirect to index.html.
The [L] flags stops the execution (https://httpd.apache.org/docs/2.4/rewrite/flags.html#flag_l)
The RewriteRule ^index\.html$ - [L]
stops the execution if the url is index.html.
So, your rewrite rule fulfill your requirements and seems correct.
When you get a 403 you maybe need to add Options +Indexes
to your config or htaccess.