Forbidden You don't have permission to access / on this server

QuantumHive picture QuantumHive · Feb 4, 2014 · Viewed 462.7k times · Source

All I wanted to do today was to write a redirect rule to a subfolder, e.g.: You enter the URL: example.com and you get redirected to example.com/subfolder

Such a simple wish. I tried to find a solution on the internet. The internet told me to add an .htaccess file in the htdocs root with:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ^$ subfolder [L]

I did this. But no success obviously, they didn't told me I had to uncomment the module in httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

So I did this too. No success again. They didn't told me I had to change my httpd.conf so that the .htaccess file would be enabled:

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

DocumentRoot "c:/Apache24/htdocs"
<Directory "c:/Apache24/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Again no success, because I get this error when entering the URL:

Forbidden You don't have permission to access / on this server.

Now I'm stuck and I couldn't find any more solutions on the internet. I'm just running Apache 2.4 on my Windows 7 machine, for private reasons.

Answer

QuantumHive picture QuantumHive · Feb 4, 2014

Found my solution thanks to Error with .htaccess and mod_rewrite
For Apache 2.4 and in all *.conf files (e.g. httpd-vhosts.conf, http.conf, httpd-autoindex.conf ..etc) use

Require all granted

instead of

Order allow,deny
Allow from all

The Order and Allow directives are deprecated in Apache 2.4.