Rewrite Wordpress' Blog Archive URL structure

陌路散爱 提交于 2019-12-13 06:12:31

问题


Currently, my website's archive page lists are displaying as:

example.com/2012/05

I would like to change the url structure to:

example.com/blog/2012/05

I've tried using Redirects in combination with rewrites but I am not sure that works well. I've also just tried to do a simple rewrite like

RewriteRule ^([0-9]+)/([0-9]+)/$ /blog/$1/$2 [L]

to capture /year/month urls and convert them but I am unsuccessful.

I know how to edit the archive navigation menu to prepend a blog/ before the rest of the url, but I can't get this rewrite to link to the page properly

It is not in a subfolder. Thank you in advance for your help.


回答1:


There is a real easy way to do this...

Under the SETTINGS > PERMALINKS, change

  /%year%/%monthnum%/%postname%/

to

  /blog/%year%/%monthnum%/%postname%/

Note that your homepage will not be on /blog/. If you wanted that you will need to create a page called 'Blog' and change your 'Posts page' under SETTINGS > READING, to the 'Blog' page you created. More on that here: http://codex.wordpress.org/Creating_a_Static_Front_Page



来源:https://stackoverflow.com/questions/10917371/rewrite-wordpress-blog-archive-url-structure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!