版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_41120504/article/details/83114730
打开config/web.php文件,添加以下代码
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => false,
'showScriptName' => false,
'rules' => [
],
],
在web目录下新建.htaccess文件
RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php`
phpStudy (Nginx版本)配置 try_files $uri $uri/ /index.php?$args;//主要是这个
server {
listen 80;
server_name www.xxxx.com www.xxxx.com;
root "D:\phpStudy\PHPTutorial\WWW\xxxx\web";
location / {
index index.html index.htm index.php;
try_files $uri $uri/ /index.php?$args;
#autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}