Ubuntu-server 下Apache2 配置.htac

发布于:2019年03月04日 已被阅读

需要开启Apache2的rewrite模块

1、打开/etc/apache2/apache2.conf

将文件中的AllowOverride None改为AllowOverride All

 image.png

2、修改mods-enable配置,添加一个软件链接

cd /etc/apache2/mods-enable
ln -s ../mods-avaiable/rewrite.load  rewrite.load

 

3、在项目根目录下添加.htaccess文件,修改rewrite规则

复制代码

<IfModule mod_rewrite.c>RewriteEngine on

#不显示index.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>

复制代码

 

4、重启服务器

service apache2 restart