1.首先啓動mod_rewrite 終端輸入:sudo a2enmod rewrite
php
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