Skip to content

Commit 1317c7e

Browse files
committed
up. nginx 配置
1 parent e0c0dc9 commit 1317c7e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

_posts/2021-11-14-Nginx-Rewrite-For-Domain.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ server {
5151
5252
# …………
5353
}
54+
5455
```
5556

5657
**另外的写法:**
@@ -74,18 +75,35 @@ server {
7475
7576
# …………
7677
}
78+
79+
```
80+
81+
**其他配置:**
82+
83+
```conf
84+
# 一般和伪静态规则在一起并放在伪静态规则之前
85+
location / {
86+
# 自动添加结尾斜杠
87+
if (!-f $request_filename) {
88+
rewrite ^/([^\.]+[^/])$ $scheme://$host/$1$2/ permanent;
89+
}
90+
# …………
91+
}
92+
7793
```
7894

7995
然后重启 nginx
8096

8197
```bash
8298
/usr/local/nginx/sbin/nginx -s reload
99+
83100
```
84101

85102
下边命令为重启 lnmp
86103

87104
```bash
88105
/root/lnmp restart
106+
89107
```
90108

91109
相关推荐:
@@ -98,4 +116,6 @@ server {
98116

99117
[「备忘」Nginx 重定向(301)相关\_电脑网络\_沉冰浮水](https://www.wdssmq.com/post/20140819797.html "「备忘」Nginx 重定向(301)相关\_电脑网络\_沉冰浮水") 「当前」
100118

119+
[「笔记」.htaccess 及 nginx.conf 可用变量一览\_电脑网络\_沉冰浮水](https://www.wdssmq.com/post/20220301043.html "「笔记」.htaccess 及 nginx.conf 可用变量一览\_电脑网络\_沉冰浮水")
120+
101121
<!--2346-->

0 commit comments

Comments
 (0)