温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-06-22 20:36:05 来源:网络 阅读:798 作者:BATMANTHE 栏目:开发技术
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

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI