Reputation: 11
I have a website running on a server. It's just an index.html
with a hello world text. Also, I have a folder named /vpn
which contains various txt files and an index.html
file.
If I try to access the URL domain/vpn
, it shows me the content of index.html
.
I just need to show the files inside the folder vpn when the user tries to access domain/vpn
.
I created an .htaccess
file with the next content in the root:
RewriteEngine on
<If "%{REQUEST_URI} == '/vpn/'">
DirectoryIndex disabled
Options +Indexes
</If>
When I try to access to vpn, it shows me a 404 error, the requested URL was not found on this server.
.htaccess
is applying the DirectoryIndex
rule (If a delete it, it shows me index.html
content again), but not the Options +Indexes
one.
I tried the same example in localhost (with XAMPP) and it's working fine.
What can be the problem?
PD: This is the content of apache2.conf
file:
Upvotes: 1
Views: 333
Reputation: 46012
When I try to acces to vpn, it shows me a 404 error, the requested URL was not found on this server.
If you are getting a "404 Not Found" then it would imply that mod_autoindex is not actually installed on your server (consequently Options +Indexes
has no effect - although it would seem from your server config that Indexes
is perhaps already enabled).
mod_autoindex is the module responsible for generating the directory listings.
I created an
.htaccess
file with the next content in the root:
Personally, I would create an additional .htaccess
file in the /vpn
directory instead:
DirectoryIndex disabled
Options +Indexes
And disable Indexes
(and set DirectoryIndex
) in the root .htaccess
file.
NB: RewriteEngine
has no place here, unless you are overriding a parent config.
If I try to access the url "domain/vpn"
Note that you should be requesting domain/vpn/
(with a trailing slash). If you omit the trailing slash then mod_dir issues a 301 redirect to append it.
Upvotes: 1