Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement url rewriting by Yii2_nginx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces Yii2_nginx how to achieve url rewriting, the content is very detailed, interested friends can refer to, hope to be helpful to you.

'urlManager' = > [/ /' urlFormat' = > 'path',' class'= > 'yii\ web\ UrlManager',' enablePrettyUrl' = > true, 'showScriptName' = > false,//false means hidden index.php' rules'= > ["/ cn.html" = > "/ cn/tv/index", "/ / {0rules'= 1}" = > "/ tv/cate" "/ cn// {0tv/detail 1}" = > "/ cn/tv/cate", "/ tv/.html" = > "/ tv/detail", "/ cn/tv/.html" = > "/ cn/tv/detail",]]

Here is the configuration of nginx

Server {listen 80; server_name www.xx.com xxx.com; root / www/xx/web; index index.php index.html index.htm; location / {index index.html index.php; if (!-e $request_filename) {rewrite ^ / (. *) / index.php last }} if ($host! = 'www.xx.com') {rewrite ^ / (. *) $https://www.xxx.com/$1 permanent;} if ($http_x_forwarded_proto! = "https") {rewrite ^ / (. *) $https://$host/$1 permanent } location ~\ .php (. *) ${fastcgi_pass php:9000; include fastcgi-php.conf; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}} server {listen 443; server_name www.xx.com; root / www/xx/web Index index.php index.html index.htm; ssl on; ssl_certificate / ssl/www.xx.com/xx.pem; ssl_certificate_key / ssl/www.xx.com/xxx.key; location / {index index.html index.php; if (!-e $request_filename) {rewrite ^ / (. *) / index.php last }} location ~\ .php (. *) ${fastcgi_pass php:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi-php.conf; include fastcgi_params;}}

It can be configured like this.

About Yii2_nginx how to achieve url rewriting to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report