码迷,mamicode.com
首页 > Web开发 > 详细

Ubuntu 16.04 本地 php 项目 访问地址去掉 index.php

时间:2018-04-03 19:19:37      阅读:474      评论:0      收藏:0      [点我收藏+]

标签:php

1. 在项目跟目录创建 .htaceess 文件, 内容如下:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

2. 在 /etc/apache2/site-avalible 文件夹中复制 000-dedault.conf 文件, 重命名为你的项目.conf, 如下:

cp 000-default.conf mysite.conf

并增加以下内容:

<VirtualHost *:80>
        ServerName www.mysite.com
        ServerAdmin webmaster@localhost
        DocumentRoot /home/www/mysite

        <Directory /home/www/mysite>
                Options Indexes FollowSymLinks
                AllowOverride All
                Require all granted
                Order allow,deny
                allow from all
        </Directory>

</VirtualHost>

3. 创建配置文件连接, 把新建的配置文件激活什么什么巴拉巴拉(当前目录 sites-avilable)

sudo a2ensite mysite.conf

4. 运行以下命令, 开启 apache2 的重写模块

sudo a2enmod rewrite [重要]

5.重启 apache2

systemctl restart apache2.service

Ubuntu 16.04 本地 php 项目 访问地址去掉 index.php

标签:php

原文地址:http://blog.51cto.com/13523022/2094391

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!