在Ubuntu上启用Apache的重写模块,你需要执行以下步骤:
打开终端(快捷键:Ctrl + Alt + T)
确保你已经安装了Apache。如果没有,请运行以下命令来安装:
sudo apt update
sudo apt install apache2
sudo a2enmod rewrite
sudo systemctl restart apache2
AllowOverride指令来控制.htaccess文件中的重写规则。编辑你的虚拟主机配置文件(通常位于/etc/apache2/sites-available/目录下),找到<Directory>部分,然后添加或修改AllowOverride指令,如下所示:<Directory /var/www/your-web-site-directory>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
将/var/www/your-web-site-directory替换为你的网站目录。
sudo systemctl restart apache2
现在,你已经成功启用了Apache的重写模块,并可以在.htaccess文件中使用重写规则。