全球主机交流论坛

标题: 哪位大侠帮我实现别的目录也能跳转 [打印本页]

作者: 云生    时间: 2013-4-19 22:50
标题: 哪位大侠帮我实现别的目录也能跳转

location ~ /index.shtml{rewrite (.*) /index.html permanent;}
随手写的 只支持站点根目录跳转 别的目录也要跳转要小改一下
上面这是一位大侠写的。只能跳转到根目录,

我想要实现在当前目录跳转。 比如/111/222/index.shtml ,就能跳转成   /111/222/index.html

我实在不会,瞎弄弄成下面这样,根本实现不了。
location ~ /(.*)/index.shtml {rewrite (.*)$ $1/index.html permanent;}

作者: 每次醒来    时间: 2013-4-19 22:54
rewrite ^/111/222/(.*).html$ http://www.123.net/111/222/$1.html permanent;


nginx 规则 论坛某大牛提供
作者: 云生    时间: 2013-4-19 23:01
每次醒来 发表于 2013-4-19 22:54
rewrite ^/111/222/(.*).html$ http://www.123.net/111/222/$1.html permanent;

111 222 只是我随机写的,
有没有规则能替代111 222
作者: 每次醒来    时间: 2013-4-19 23:02
云生 发表于 2013-4-19 23:01
111 222 只是我随机写的,
有没有规则能替代111 222

111 和 222 目录也是随机的?
作者: 每次醒来    时间: 2013-4-19 23:03
哥也是菜鸟 用 (.*) 替换试试
作者: 每次醒来    时间: 2013-4-19 23:04

rewrite ^/(.*)/(.*)/(.*).html$ http://www.123.net/$1/$2/$3.html permanent;

菜鸟瞎蒙试试
作者: aarwwefdds    时间: 2013-4-19 23:10
location ~ .*/index\.shtml{rewrite (.*)/index\.shtml $1/index.html permanent;}

刚才给你发了新的 其实貌似不用location也行
作者: 云生    时间: 2013-4-19 23:10
每次醒来 发表于 2013-4-19 23:03
哥也是菜鸟 用 (.*) 替换试试

哈哈,成功了,感谢感谢
rewrite  ^/(.*)\.shtml$ /$1.html permanent;
作者: 每次醒来    时间: 2013-4-19 23:11
云生 发表于 2013-4-19 23:10
哈哈,成功了,感谢感谢
rewrite  ^/(.*)\.shtml$ /$1.html permanent;

流弊了
作者: 云生    时间: 2013-4-19 23:12
aarwwefdds 发表于 2013-4-19 23:10
location ~ .*/index\.shtml{rewrite (.*)/index\.shtml $1/index.html permanent;}

刚才给你发了新的 其 ...

rewrite  ^/(.*)\.shtml$ /$1.html permanent;
我用这个成功了,感谢!
作者: kwx    时间: 2013-4-19 23:13
云生 发表于 2013-4-19 23:12
rewrite  ^/(.*)\.shtml$ /$1.html permanent;
我用这个成功了,感谢!

哦也
作者: aarwwefdds    时间: 2013-4-19 23:14
云生 发表于 2013-4-19 23:12
rewrite  ^/(.*)\.shtml$ /$1.html permanent;
我用这个成功了,感谢!

我那个不行?
作者: aarwwefdds    时间: 2013-4-19 23:20
NginX的规则还是挺好写的 熟悉一下正则就好 我比较讨厌Apache的XML式的规则 而且是十分的讨厌。。




欢迎光临 全球主机交流论坛 (https://loc.888543.xyz/) Powered by Discuz! X3.4