我尝试在Apache Serverur 2.4和Debian 8上启用重写模块我创建了一个子域
如果我用以下方式创建一个PHP文件。
<?php
if(!function_exists('apache_get_modules') ){ phpinfo(); exit; }
$res = 'Module Unavailable';
if(in_array('mod_rewrite',apache_get_modules()))
$res = 'Module Available';
echo apache_get_version();
?>
它显示"可用模块"
在Global Directive(/etc/apache2/apache2.conf)中,我创建了:
<Directory /var/dev/>
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
我在根网络文件夹上创建了一个.htaccess文件
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^foo.html$ test.html
和test.html文件!
在Adpache错误日志中我有:
[thu 12月22日11:36:44.828831 2016] [核心:info] [pid 1884] [客户83.145.73.220:58115] ah00128:不存在文件:/home/dev/foo.html
感谢您的帮助
我也有同样的问题。您需要在终端中要做的就是
sudo a2enmod rewrite
然后只需重新启动apache2
sudo service apache2 restart