ubuntu16.04 apache下去掉php项目的index.php

1.首先启动mod_rewrite 终端输入:sudo a2enmod rewritephp

2.更改/etc/apache2/apache2.conf(ubuntu16.04没有httpd.conf文件,配置文件是apache2.conf)文件,主要是 AllowOverride None 改成AllowOverride Allapache

3.在项目根目录下新建一个.htaccess文件,内容写:ubuntu

<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.重启Apacheide

service apache2 restart
相关文章
相关标签/搜索