ubuntu16.04apache下去掉CI的index.php

时间:2021-01-16 19:59:15

ubuntu16.04apache下去掉C网址的index.php

1.        首先启动mod_rewrite

终端输入:sudo a2enmod rewrite

2.        更改/etc/apache2/apache2.conf(没有httpd.conf文件,不用找了)文件,主要是AllowOverride All

ubuntu16.04apache下去掉CI的index.php

3.        如果project建立在var/www/html下,在project文件夹下touch一个.htaccess文件(每次一touch这个文件总是不显示,所以我先新建一个文本文档然后改名字),内容写

RewriteEngine on

RewriteCond $1 !^(index\.php|images|robots\.txt)

RewriteRule ^(.*)$ /index.php/$1 [L]

ubuntu16.04apache下去掉CI的index.php

(我的project叫CI,就在这个文件夹下建.htaccess )

4.        然后重启一下apache就好了。

sudo /etc/init.d/apache2 restart

5.       但是打开的页面没有JS和CSS,把上面第二行RewriteCond $1 !^(index\.php|images|robots\.txt)改成RewriteCond $1 !^(index\.php|static|robots\.txt)就好了(因为我的js和css放在根目录的static文件夹下)

ubuntu16.04apache下去掉CI的index.php