本教学使用环境介绍
伺服器端:Ubuntu 18.04 LTS
资料库:Mariadb 10.1.34(Mysql)
语言版本:php 7.3
本机端:MacOS High Sierraphp
首先安装好 apache 后,启用 rewrite 功能sql
$ a2enmod rewrite
而后再到 /etc/apache2/apache2.conf
添加内容apache
$ nano /etc/apache2/apache2.conf
内容为ide
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>
记得将路径设为你的网站根目录路径呦!网站
接着将 apache reloadui
service apache2 reload
而后去你的网站根目录中添加档案为 .htaccess,并加入如下内容code
Options -Indexes Options +FollowSymlinks RewriteEngine on
在同一个 .htaccess
档案中添加 RewriteRule,就像这样it
Options -Indexes Options +FollowSymlinks RewriteEngine on RewriteRule ^admin/index$ admin/index.php
这样只要访问路径 /admin/index
就等因而访问了 /admin/index.php
,apache已经帮你隐藏副档名了io
Line ID:ianmac
QQ:1258554508service