紫禁城您没有权限访问/在此服务器上 [英] Forbidden You don't have permission to access / on this server
问题描述
所有我想今天要做的是写一个重定向规则到子文件夹,例如: 您输入的网址: example.com ,你会得到重定向到 example.com/subfolder
这样一个简单的愿望。我试图在互联网上找到一个解决方案。互联网让我在htdocs目录根目录添加一个的.htaccess 文件:
RewriteEngine叙述上
的RewriteCond%{HTTP_HOST} ^例如\ .COM $
重写规则(。*)http://www.example.com/$1 [R = 301,L]
重写规则^ $子文件夹[L]
我这样做。但是没有成功显然,他们并没有告诉我,我不得不取消注释在模块的的httpd.conf
的LoadModule rewrite_module模块/ mod_rewrite.so
所以我这样做了。没有成功的一次。他们没有告诉我,我不得不改变我的的httpd.conf 使的.htaccess 文件将被启用:
<目录/>
有FollowSymLinks
设置AllowOverride无
订单拒绝,允许
所有拒绝
< /目录>
的DocumentRootC:/ Apache24 / htdocs目录
<目录C:/ Apache24 / htdocs目录>
选择指标的FollowSymLinks
设置AllowOverride所有
要求所有批准
< /目录>
同样没有成功,因为我得到输入URL时,这个错误:
紫禁城您没有权限访问/在此服务器上。
现在我坚持,我不能在互联网上找到更多的解决方案。我只是运行的Apache 2.4在我的Windows 7计算机上,用于私人的原因。
发现我的解决方案感谢的使用的.htaccess的错误和mod_rewrite的
对于的Apache 2.4 ,并在所有的* conf文件(如的httpd-vhosts.conf,http.conf中,的httpd-autoindex.conf ..等)使用
要求所有批准
而不是
订购允许,拒绝
所有允许
在订单和允许的指令是德precated在的Apache 2.4
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.
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.
这篇关于紫禁城您没有权限访问/在此服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!