7

wordpress博客永久地址的二次重写

 3 years ago
source link: https://www.cnxct.com/wordpress%e5%8d%9a%e5%ae%a2%e6%b0%b8%e4%b9%85%e5%9c%b0%e5%9d%80%e7%9a%84%e4%ba%8c%e6%ac%a1%e9%87%8d%e5%86%99/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
wordpress博客永久地址的二次重写 – CFC4N的博客

在很久很久以前,从前有座山,山上有个庙,庙里有个和尚在讲故事,讲什么呢?

从前有座山,山上有个庙,庙里有个和尚在讲故事,讲什么呢……

言归正传,很久以前,博客的URL是这种形式http://www.cnxct.com/cnxct/612/ 这种形式,后来呢,听网上SEOer说,为了更好的SEO,URL中包含关键词,可提高权重等等等等。遂打算把老的URL形式重写成hhttp://www.cnxct.com/%e6%88%91%e6%9c%80%e8%bf%91%e5%be%88%e6%b5%ae%e8%ba%81/这种形式。

服务器web services是nginx,需要更改如下规则

location / {
if (!-e $request_filename) {
rewrite ^/cnxct/(\d+)/?$ /?p=$1 permanent;
rewrite . /index.php last;
}
}

把/cnxct/数字/这种形式的老URL重写到/?p=数字这种形式,然后,Wordpress里在启用新的URL形式,让wordpress再把/?p=数字形式的URL再重写到目标URL。
效果如下图

wordpress系统URL两次重写

一网友问到,遂共享出来

莿鸟栖草堂 由 CFC4N 创作,采用 知识共享 署名-非商业性使用-相同方式共享(3.0未本地化版本)许可协议进行许可。基于http://www.cnxct.com上的作品创作。转载请注明转自:wordpress博客永久地址的二次重写

No related posts.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK