所有栏目设置为伪静态,但是在添加文章的时候,点击图片和超链接等按钮会弹出404错误页面(如图)
如下是我的伪静态设置代码
文章
rewrite "^/\w+/\d+/\d+/(\d+).html$" /article.php?id=$1 last;
rewrite "^/\w+/\d+/\d+/(\d+)_(\d+).html$" /article.php?id=$1&p=$2 last;
列表页
rewrite "^/(\w+)(/|/index\.html)$" /category.php?dir=$1 last;
rewrite "^/(\w+)/index_(\d+).html$" /category.php?dir=$1&page=$2 last; #这个是分页
标签 使用标签所属栏目规则 /{CDIR}/{TKEY}{EXT},
当前TKEY生成是没有分隔符的 所以用\w+匹配
如果有分隔符的话,要把分隔符也在加规则里去
例如:([\w\-]+) -为分隔符
rewrite "^/.+/([\w\-]+).html$" /tag.php?tkey=$1 last;
rewrite "^/.+/([\w\-]+)_(\d+).html$" /tag.php?tkey=$1&page=$2 last;
用户APP
rewrite "^/user$" /public/api.php?app=user last;
用户中心 我的首页
rewrite "^/user/home$" /public/api.php?app=user&do=home last;
用户中心 我的内容
rewrite "^/user/manage/(\w+)$" /public/api.php?app=user&do=manage&pg=$1 last;
rewrite "^/user/manage$" /public/api.php?app=user&do=manage last;
发表文章
rewrite "^/user/publish$" /public/api.php?app=user&do=manage&pg=publish last;
我的文章
rewrite "^/user/article$" /public/api.php?app=user&do=manage&pg=article last;
我的分类
rewrite "^/user/category$" /public/api.php?app=user&do=manage&pg=category last;
我的评论
rewrite "^/user/comment$" /public/api.php?app=user&do=manage&pg=comment last;
我的私信
rewrite "^/user/inbox/(\d+)$" /public/api.php?app=user&do=manage&pg=inbox&user=$1 last;
rewrite "^/user/inbox$" /public/api.php?app=user&do=manage&pg=inbox last;
用户中心 账号设置
rewrite "^/user/profile/(\w+)$" /public/api.php?app=user&do=profile&pg=$1 last;
rewrite "^/user/profile$" /public/api.php?app=user&do=profile last;
用户第三方登陆
rewrite "^/user/login/(\w+)$" /public/api.php?app=user&do=login&sign=$1 last;
用户登陆
rewrite "^/user/login$" /public/api.php?app=user&do=login last;
用户注册
rewrite "^/user/register$" /public/api.php?app=user&do=register last;
用户退出
rewrite "^/user/logout$" /public/api.php?app=user&do=logout last;
用户找回密码
rewrite "^/user/findpwd$" /public/api.php?app=user&do=findpwd last;
用户主页
这里的前缀 /user/ 要根据 URL设置里的 用户URL 设置
rewrite "^/user/(\d+)/(\w+)/$" /public/api.php?app=user&do=$2&uid=$1 last;
rewrite "^/user/(\d+)/$" /public/api.php?app=user&do=home&uid=$1 last;
rewrite "^/user/(\d+)/(\d+)/$" /public/api.php?app=user&do=home&uid=$1&cid=$2 last;
rewrite "^/user/(\d+)/favorite/(\d+)/$" /public/api.php?app=user&do=favorite&uid=$1&id=$2 last;
系统API
rewrite "^/api$" /public/api.php last;
评论
rewrite "^/comment$" /public/api.php?app=comment last;
搜索
rewrite "^/search$" /public/api.php?app=search last;
公共API 验证码之类的
rewrite "^/public/(\w+)$" /public/api.php?app=public&do=$1 last;
收藏功能
rewrite "^/favorite$" /public/api.php?app=favorite last;
rewrite "^/favorite/(\d+)/$" /public/api.php?app=favorite&id=$1 last;
自定义表单
rewrite "^/forms$" /public/api.php?app=forms last;
rewrite "^/forms/(\w+)$" /public/api.php?app=forms&do=$1 last;
rewrite "^/forms/(\d+)/$" /public/api.php?app=forms&id=$1 last;