Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to implement url rewriting by Yii2_nginx

Shulou Source: shulou.com Published: 2022-06-01 23:43:35 11月14日 Update

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.

Tags: Content more help configuration good interest guys buddies articles knowledge articles references Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Huawei vpn Shulou Information Xiaomi