您好,登錄后才能下訂單哦!
這篇文章給大家介紹Yii2_nginx怎樣實現url重寫,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
'urlManager' => [ //'urlFormat' => 'path', 'class'=>'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false,//false 表示隱藏index.php 'rules'=>[ "/cn.html"=>"/cn/tv/index", "/<id:\w+>/{0,1}"=>"/tv/cate", "/cn/<id:\w+>/{0,1}"=>"/cn/tv/cate", "/tv/<id:(.*)>.html"=>"/tv/detail", "/cn/tv/<id:(.*)>.html"=>"/cn/tv/detail", ] ],
下面是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; } }
這樣配置即可
關于Yii2_nginx怎樣實現url重寫就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。