ray1980 avatar

修改贴子链接后发表评论出现404 Not Found

🕑 by ray1980

原先的 t-1改为了topic/1 n-1改为了node/1 发贴正常, 发表评论后,会跳到 xxx.com/topic/1/1#new-comment 然后网页404 Not Found

请问下这个要如何改啊?

💘 相关文章

评论

共10条关于"修改贴子链接后发表评论出现404 Not Found"的评论

ego008 avatar
#1 ego008 回复

用哪个版本? 若方便发个网址看看

ego008 avatar
#3 ego008 回复

修改.htaccess 增加对格式 /topic/1/1 解析 或 把评论页数修改为 /topic/1-1 格式

ray1980 avatar
#4 ray1980 回复

@ego008 用的是nginx,不知道/topic/1/1,对应的是哪个地址

ray1980 avatar
#6 ray1980 回复

这是我的配置文件,里面有这一条 location / { rewrite ^/node/([0-9]+)(/([0-9]))?$ /nodepage.php?cid=$1&page=$3 last; rewrite ^/topic/([0-9]+)(/([0-9]))?$ /topicpage.php?tid=$1&page=$3 last; rewrite ^/page/([0-9]+)$ /indexpage.php?page=$1 last; rewrite ^/notifications$ /notifications.php last; rewrite ^/favorites$ /favorites.php last; rewrite ^/qqlogin$ /qqlogin.php last; rewrite ^/qqcallback$ /qqcallback.php last; rewrite ^/qqsetname$ /qqsetname.php last; rewrite ^/wblogin$ /wblogin.php last; rewrite ^/wbcallback$ /wbcallback.php last; rewrite ^/wbsetname$ /wbsetname.php last; rewrite ^/feed$ /feed.php last; rewrite ^/robots.txt$ /robots.php last; rewrite ^/sitemap-([0-9]+)$ /sitemap.php?id=$1 last; rewrite ^/forgot$ /forgot.php last; rewrite ^/upload-(650|590)$ /upload.php?mw=$1 last; rewrite ^/viewat-(desktop|mobile)$ /viewat.php?via=$1 last; rewrite ^/goto-t-([0-9]+)$ /gototopic.php?tid=$1 last; rewrite ^/member/(.+)$ /member.php?mid=$1 last; rewrite ^/newpost/([0-9]+)$ /newpost.php?cid=$1 last;

ego008 avatar
#7 ego008 回复

修改试一下 rewrite ^/topic/([0-9]+)(/([0-9]))?$ /topicpage.php?tid=$1&page=$3 last; rewrite ^/topic/([0-9]+)/?([0-9])$ /topicpage.php?tid=$1&page=$2 last;

ego008 avatar
#9 ego008 回复

@ray1980 我没环境测试,看哪个行,不行再微调。 目前 rewrite ^/topic/([0-9]+)(/([0-9]*))?$ /topicpage.php?tid=$1&page=$3 last; 能打开 /topic/1-1 的格式

ray1980 avatar
#10 ray1980 回复

@ego008 谢谢大神 用了这条就解决了 rewrite ^/topic/([0-9]+)(/([0-9]*))?$ /topicpage.php?tid=$1&page=$3 last;

能跳转到 topic/77#new-comment

谢谢!

写一条评论

Based on Golang + fastHTTP + sdb | go1.17.3 Processed in 0ms