laravel5中如何隐藏index.php后缀
1、sudo vim /etc/hosts
添加: 127.0.0.1 xuan.blog(后面我发现这里其实可以随便填。)
2、启用mod_rewrite
sudo a2enmod rewrite
然后重启apache服务器
sudo service apache2 restart
3、修改apache2.conf
sudo vim /etc/apache2/apache2.conf
在最后添加:
ServerName localhost DirectoryIndex index.html index.htm index.php
并且修改:
Options Indexes FollowSymLinks AllowOverride all(这里改为all) Require all granted
4、添加blog.conf (配置虚拟站点,这里哪个名字也是可以改的)
sudo vim /etc/apache2/sites-available/blog.conf
添加:
ServerName xuan.blog DocumentRoot /var/www/html/blog/public ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
5、启用虚拟站点
sudo a2ensite blog.conf sudo service apache2 reload
6、最后再设置下权限
sudo chmod -R 0777 /var/www/html/blog