我在这个文件夹etc / apache2 / apache2.conf中更改了一行
使用:AllowOverride None
到AllowOverride 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文件时,我得到了这个: 禁
您无权访问此服务器上的/index.php。 服务器无法读取htaccess文件,拒绝访问是安全的 位于mydomain.com端口80的Apache / 2.4.12(Ubuntu)服务器
我使用的服务器系统是:Ubuntu 15.10 Server 64-Bit 我似乎无法弄清楚我哪里出错,我是全新的服务器也做了大量的研究,但我似乎仍然受限于我的能力,我将不胜感激任何帮助:)