全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1762|回复: 12
打印 上一主题 下一主题

哪位大侠帮我实现别的目录也能跳转

[复制链接]
跳转到指定楼层
1#
发表于 2013-4-19 22:50:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

我实在不会,瞎弄弄成下面这样,根本实现不了。
location ~ /(.*)/index.shtml {rewrite (.*)$ $1/index.html permanent;}
2#
发表于 2013-4-19 22:54:36 | 只看该作者
rewrite ^/111/222/(.*).html$ http://www.123.net/111/222/$1.html permanent;


nginx 规则 论坛某大牛提供
3#
 楼主| 发表于 2013-4-19 23:01:32 | 只看该作者
每次醒来 发表于 2013-4-19 22:54
rewrite ^/111/222/(.*).html$ http://www.123.net/111/222/$1.html permanent;

111 222 只是我随机写的,
有没有规则能替代111 222
4#
发表于 2013-4-19 23:02:19 | 只看该作者
云生 发表于 2013-4-19 23:01
111 222 只是我随机写的,
有没有规则能替代111 222

111 和 222 目录也是随机的?
5#
发表于 2013-4-19 23:03:23 | 只看该作者
哥也是菜鸟 用 (.*) 替换试试
6#
发表于 2013-4-19 23:04:40 | 只看该作者

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

菜鸟瞎蒙试试
7#
发表于 2013-4-19 23:10:11 | 只看该作者
location ~ .*/index\.shtml{rewrite (.*)/index\.shtml $1/index.html permanent;}

刚才给你发了新的 其实貌似不用location也行
8#
 楼主| 发表于 2013-4-19 23:10:12 | 只看该作者
每次醒来 发表于 2013-4-19 23:03
哥也是菜鸟 用 (.*) 替换试试

哈哈,成功了,感谢感谢
rewrite  ^/(.*)\.shtml$ /$1.html permanent;
9#
发表于 2013-4-19 23:11:17 | 只看该作者
云生 发表于 2013-4-19 23:10
哈哈,成功了,感谢感谢
rewrite  ^/(.*)\.shtml$ /$1.html permanent;

流弊了
10#
 楼主| 发表于 2013-4-19 23:12:09 | 只看该作者
aarwwefdds 发表于 2013-4-19 23:10
location ~ .*/index\.shtml{rewrite (.*)/index\.shtml $1/index.html permanent;}

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

rewrite  ^/(.*)\.shtml$ /$1.html permanent;
我用这个成功了,感谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2026-1-13 17:54 , Processed in 0.070494 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表