WordPress博客链接路径设置及新浪SAE设置

一般有几种被普遍推荐的设置方法:

/%category%/%postname%.html

/archives/%postname%.html

/archives/%post_id%.html

/%postname%.html

关于/%postname%.html链接优点

1.链接较短更利于搜索引擎收录

2.URL中能体现文章主题内容

3.没有目录结构方便以后调整

4.可以设置关键字
有的博客设置会报404错误可以设置如下
根据官方所显示,将以下代码
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

保存为.htaccess格式保存到根目录下就可以了。然后进入后台更改固定链接应该就可以了。

针对新浪SAE以上方式处理还是会报404错误需要单独处理:
新浪SAE的前端采用的是nginx,nginx是不识别.htaccess
修改SAE SDK站点目录下的的config.yaml,例如在config.yaml下面添加以下三行:
handle:
– rewrite: if(!is_dir() && !is_file()) goto “index.php?%{QUERY_STRING}”
– errordoc: 404 /404.php

页面重定向

当 url 匹配 urldir/(.*) ,并且 输入 header referer 等于 sina 时,跳转至页面 /usr/$1,$1 表示刚刚匹配的 urldir/(.*) 中的 (.*) 部分。
– rewrite: if (path ~ “urldir/(.*)” && in_header[“referer”] == “sina”) goto “/url/$1″

当 url 匹配 urldir/(.*),并且请求的是一个目录时,跳转至 /url/$1
– rewrite: if(is_dir( ) && path ~ “urldir/(.*)”) goto “/url/$1″

当 url 匹配 path,并且请求的不是一个文件时,跳转至 /url/query.php
– rewrite: if(! is_file() && path ~ “path”) goto “/url/query.php”

当查询串等于so,并且 url 以 zhaochou 结尾时,跳转至 /url/%1,%1 表示 query_string 匹配到的部分。
– rewrite: if(query_string ~ “^(so)$” && path ~ “zhaochou$”) goto “/url/%1″

当查询串不包含sohu,并且 url 以 zhaochou 结尾时,跳转至 /url/query.php?%{QUERY_STRING},%{QUERY_STRING} 表示查询串。
– rewrite: if(query_string !~ “sohu” && path ~ “zhaochou$”) goto “/url/query.php?${QUERY_STRING}”

如果 url 既不是文件,也不是目录,跳转至 index.php?%{QUERY_STRING}
– rewrite: if( !is_file() && !is_dir()) goto “index.php?%{QUERY_STRING}”

© 版权声明
THE END
喜欢就支持一下吧
点赞0赞赏 分享
评论 共1条

请登录后发表评论

    • 头像技术部落0