1. 在项目跟目录创建
2. 在
.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 [email protected] 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