0

我在此文件夹 etc/apache2/apache2.conf 中更改了一行:AllowOverride NonetoAllowOverride All 并确保AccessFileName .htaccess设置正确。

然后使用以下命令启用重写:

sudo a2enmod rewrite

然后重启apache2:

sudo service apache2 restart

这是我的简单 .htaccess 代码:

# 1 ---- Establish a custom 404 File not Found page ----

ErrorDocument 404 /index.php

# 2 ---- Prevent directory file listing in all of your folders ----

IndexIgnore *

#block hotlinking
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ style/logo/logo_icon.png [NC,R,L]

然后,当我访问主 index.php 文件时,我得到了这个:Forbidden

您无权访问此服务器上的 /index.php。服务器无法读取 htaccess 文件,拒绝访问是安全的 Apache/2.4.12 (Ubuntu) 服务器在 mydomain.com 端口 80

我正在使用的服务器系统是:Ubuntu 15.10 Server 64-Bit 我似乎无法弄清楚我哪里出了问题,我对服务器是全新的,也做了很多研究但是我似乎仍然受到我的能力的限制,我将不胜感激任何帮助 :)

4

0 回答 0