路由美化问题:url始终显示的是首页页面的内容 [ 2.0 版本 ]
nginx设置:
server {
listen 80;
server_name yii.com alias www.yii.com;
location / {
root d:/web/www/yii/web/;
index index.html index.htm default.html default.htm index.php default.php app.php u.php;
include d:/web/www/yii/web/up-*.conf;
try_files $uri $uri/ /index.php$is_args$args;
}
autoindex off;
include advanced_settings.conf;
#include expires.conf;
location ~* .*\/(attachment|attachments|uploadfiles|avatar)\/.*\.(php|php5|phps|asp|aspx|jsp)$ {
deny all;
}
location ~ ^.+\.php {
root d:/web/www/yii/web/;
fastcgi_pass bakend;
fastcgi_index index.php;
fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi.conf;
}
}
#server yii.com end}
第二个:config下的web.php设置:
在
'components' => [
//rewrite路由(pathinfo)的形式访问 yii配置pathinfo
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'enableStrictParsing' => true,
'rules' => [
'/' => '/site/index', //这里
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
"<controller:\w+>/<action:\w+>"=>"<controller>/<action>",
],
],
目前url访问是这样的:
http://www.yii.com/index.php?r=site%2Findex
http://www.yii.com/index.php?r=site%2Fabout
http://www.yii.com/index.php?r=site%2Fcontact
http://www.yii.com/index.php?r=site%2Flogin
上面这些路径访问正常
想实现 像下面的url:
http://www.yii.com/
http://www.yii.com/about
http://www.yii.com/contact
http://www.yii.com/login
现在访问这些目录显示的页面内容都是首页的,不知道是哪里错了
共 2 个回答
dazhaimen
注册时间:2017-12-10
最后登录:2019-04-03
在线时长:0小时43分
最后登录:2019-04-03
在线时长:0小时43分
- 粉丝0
- 金钱5
- 威望0
- 积分5