1、httpd.conf配置文件中加载mod_rewrite.so模块
//去除前面有#号
例:LoadModule rewrite_module modules/mod_rewrite.so
2、phpStudy 》 打开配置文件 》 vhost.conf-ini
AllowOverride None 将None改为 All
<VirtualHost _default_:80>
DocumentRoot "D:\phpStudy\PHPTutorial\WWW"
<Directory "D:\phpStudy\PHPTutorial\WWW">
Options +Indexes +FollowSymLinks +ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
3、config.php配置文件'pathinfo_fetch' => ['ORIG_PATH_INFO', 'REDIRECT_PATH_INFO', 'REDIRECT_URL']
4、把下面的内容保存为.htaccess文件放到入口文件的同级目录下
.htaccess文件内容
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
5、重启Apache,然后输入测试网址(域名/模块名/控制器/操作方法)