在Ubuntu下开启apache伪静态功能

本篇将介绍如何在Ubuntu下开启apache伪静态功能。

.htaccess是apache http server的配置文件,如果要想确定伪静态开启,就必须调试.htaccess.

如何在Ubuntu下开启.htaccess?

首先打开 /etc/apache2/sites-available/default,你会发现类似以下的文本:

DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

你需要将AllowOverride None 改成 AllowOverride all

然后重新加载apache2:

/etc/init.d/apache2 reload

调试.htaccess rewrite 模式

sudo a2enmod rewrite

模式开启后,确保你的.htaccess已经在所需要网站的根目录安装,你的伪静态功能就可以实现了。