Home > Backend Development > PHP Problem > How to remove index.php in Ubuntu

How to remove index.php in Ubuntu

藏色散人
Release: 2023-03-10 13:40:02
Original
1834 people have browsed it

乌版图去掉index.php的方法:1、在项目根目录创建“.htaceess”文件;2、复制“000-dedault.conf”文件并重命名;3、创建配置文件;4、开启apache2的更新模块;5、重启apache2即可。

How to remove index.php in Ubuntu

本文操作环境:ubuntu 16.04系统、PHP7.1版,DELL G3电脑

乌版图怎么去掉index.php?

Ubuntu 16.04 本地 php 项目访问地址移除 index.php

1.在项目跟目录创建.htaceess文件,内容如下:

1

2

3

4

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

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

Copy after login

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

1

cp 000-default.conf mysite.conf

Copy after login

并增加以下内容:

1

2

3

4

5

6

7

8

9

10

11

12

<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>

Copy after login

3.创建配置文件连接,把新建的配置文件激活什么东西巴拉巴拉(当前目录站点-可用)

1

sudo a2ensite mysite.conf

Copy after login

4.运行以下命令,开启apache2的更新模块

1

sudo a2enmod rewrite [重要]

Copy after login

5.重启apache2

1

systemctl restart apache2.service

Copy after login

【推荐学习:PHP视频教程

The above is the detailed content of How to remove index.php in Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template