Forbidden 您无权访问/在此服务器上 [英] Forbidden You don't have permission to access / on this server

查看:35
本文介绍了Forbidden 您无权访问/在此服务器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我今天想做的就是写一个重定向规则到一个子文件夹,例如:您输入 URL:example.com,然后您将被重定向到 example.com/subfolder

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

好简单的愿望.我试图在互联网上找到解决方案.互联网告诉我在 htdocs 根目录中添加一个 .htaccess 文件:

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]

我做到了.但显然没有成功,他们没有告诉我必须在 httpd.conf 中取消对模块的注释:

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

所以我也这样做了.又没有成功.他们没有告诉我必须更改我的 httpd.conf 以便启用 .htaccess 文件:

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>

再次没有成功,因为我在输入 URL 时出现此错误:

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

禁止您无权访问/在此服务器上.

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

现在我被卡住了,我无法在互联网上找到更多解决方案.出于私人原因,我只是在我的 Windows 7 机器上运行 Apache 2.4.

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.

推荐答案

感谢 .htaccess 和 mod_rewrite 出错
对于 Apache 2.4 和所有 *.conf 文件(例如 httpd-vhosts.conf、http.conf、httpd-autoindex.conf ..etc)使用

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

代替

Order allow,deny
Allow from all

Apache 2.4 中不推荐使用 OrderAllow 指令.

The Order and Allow directives are deprecated in Apache 2.4.

这篇关于Forbidden 您无权访问/在此服务器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆