返回列表 发帖
查看: 290|回复: 8

[求助] 求助,网站目录下的论坛如何写静态规则

33

主题

95

回帖

136

积分

渐入佳境

贡献
0 点
金币
5 个
QQ
发表于 2025-3-3 21:31:35 | 查看全部 |阅读模式
比如网站根目录下有一个站,然后在根目录下新建一个目录再建一个站,

独立主机linux系统宝塔nginx
后台应该是这个可用
  1. rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
  2. rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
  3. rewrite ^([^\.]*)/jdwx-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  4. rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
  5. rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  6. rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
  7. rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
  8. if (!-e $request_filename) {
  9.         return 404;
  10. }
复制代码
然后是怎么改写添加到原静态规则下方可用?
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/jdwx-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;if (!-e $request_filename) {        return 404;}
Nginx Web Serverrewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/jdwx-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;if (!-e $request_filename) {        return 404;}Nginx Web Server
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/jdwx-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;if (!-e $request_filename) {        return 404;
}宝塔nginx
Nginx Web Serverrewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;rewrite ^([^\.]*)/jdwx-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;if (!-e $request_filename) {        return 404;}
我知道答案 回答被采纳将会获得1 贡献 已有8人回答
回复

使用道具 举报

33

主题

95

回帖

136

积分

渐入佳境

贡献
0 点
金币
5 个
QQ
 楼主| 发表于 2025-3-3 21:32:32 | 查看全部
不能编辑帖子了,下方的代码请忽略
回复

使用道具 举报

33

主题

95

回帖

136

积分

渐入佳境

贡献
0 点
金币
5 个
QQ
 楼主| 发表于 2025-3-3 21:34:53 | 查看全部
我操,官方真的是体验差,不能编辑帖子也不能删,
加入新建网站在bbs目录下
回复

使用道具 举报

35

主题

531

回帖

769

积分

自成一派

贡献
28 点
金币
44 个
QQ
发表于 2025-3-3 22:17:07 | 查看全部
多和AI沟通,看它怎么说。
回复

使用道具 举报

33

主题

95

回帖

136

积分

渐入佳境

贡献
0 点
金币
5 个
QQ
 楼主| 发表于 2025-3-3 22:44:30 来自手机 | 查看全部
IsaacZ 发表于 2025-3-3 22:17
多和AI沟通,看它怎么说。

试过了没有用
回复

使用道具 举报

35

主题

531

回帖

769

积分

自成一派

贡献
28 点
金币
44 个
QQ
发表于 2025-3-3 23:51:25 | 查看全部
先看看这个旧帖:宝塔环境下Discuz 3.5 论坛设置 URL 静态化(伪静态)方法 - Discuz! X 教程 - Powered by Discuz!
https://www.dismall.com/forum.php?mod=viewthread&tid=18537
回复

使用道具 举报

33

主题

95

回帖

136

积分

渐入佳境

贡献
0 点
金币
5 个
QQ
 楼主| 发表于 2025-3-4 00:54:07 来自手机 | 查看全部
IsaacZ 发表于 2025-3-3 23:51
先看看这个旧帖:宝塔环境下Discuz 3.5 论坛设置 URL 静态化(伪静态)方法 - Discuz! X 教程 - Powered by ...

这个是根目录的常规操作,我这个是问目录下的网站的静态规则
回复

使用道具 举报

13

主题

3146

回帖

5349

积分

应用开发者

贡献
372 点
金币
164 个
QQ
发表于 2025-3-4 08:02:30 | 查看全部
Discuz3.4二级目录伪静态web.config配置win2008+IIS7.5环境
https://bbs.piaoxian.net/thread-170716-1-1.html
(出处: 飘仙建站论坛)


可以参考这个;
或者是 直接让ai帮你把 这个伪静态规则 转换成 Nginx格式的

回复

使用道具 举报

75

主题

524

回帖

640

积分

自成一派

贡献
3 点
金币
0 个
发表于 2025-3-4 08:14:47 | 查看全部
使用宝塔建站时,管理面板里有默认的DZ伪静态规则,你选择一下即可。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 关注公众号
  • 有偿服务微信
  • 有偿服务QQ

手机版|小黑屋|Discuz! 官方交流社区 ( 皖ICP备16010102号 |皖公网安备34010302002376号 )|网站地图|star

GMT+8, 2025-4-30 18:11 , Processed in 0.047921 second(s), 8 queries , Redis On.

Powered by Discuz! W1.0 Licensed

Cpoyright © 2001-2025 Discuz! Team.

关灯 在本版发帖
有偿服务QQ
有偿服务微信
返回顶部
快速回复 返回顶部 返回列表