Linux下给WordPress建设伪静态

来历:Linux公社  作者:Linux
WordPress是一个被普及操作的Blog体系,因为它的贫弱,甚至在培育提拔网站的时间也可以用到。而其支撑伪静态(Wordpress Permalinks)的结局更被津津有味。在操作LAMP平台的时间,开启Wordpress的伪静态是很轻易的,而在zeus下,却出了一些小费事,记录如下:

  环境:
  ZWS 4.3r3 FreeBSD i386 6.1-RELEASE
  WordPress 2.0.4(目前最新版是2.5.1)

  启用 htaccess Support

  启用后,却发明只能让wordpress 完成上面的链接方法:

  http://www.linuxidc.com/index.php/yyyy/mm/dd/post-name/

  而我想完成的,是这样的链接方法:
  http://www.linuxidc.com/yyyy/mm/dd/post-name/

  盘查了一下wordpress 文档,需求apache mod_rewrite 支撑才干完成这种链接方法。

  启用 Request Rewriting

  在Rewrite Script输入以下代码:
RULE_0_START:
# get the document root
map path into SCRATCH:DOCROOT from /
# initialize our variables
set SCRATCH:ORIG_URL = %{URL}
set SCRATCH:REQUEST_URI = %{URL}

# see if theres any queries in our URL
match URL into $ with ^(.*)\?(.*)$
if matched then
set SCRATCH:REQUEST_URI = $1
set SCRATCH:QUERY_STRING = $2
endif
RULE_0_END:

RULE_1_START:
# prepare to search for file, rewrite if its not found
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

# check to see if the file requested is an actual file or
# a directory with possibly an index. don’t rewrite if so
look for file at %{SCRATCH:REQUEST_FILENAME}
if not exists then
look for dir at %{SCRATCH:REQUEST_FILENAME}
if not exists then
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
goto QSA_RULE_START
endif
endif

# if we made it here then its a file or dir and no rewrite
goto END
RULE_1_END:

QSA_RULE_START:
# append the query string if there was one originally
# the same as [QSA,L] for apache
match SCRATCH:ORIG_URL into % with \?(.*)$
if matched then
set URL = %{URL}&%{SCRATCH:QUERY_STRING}
endif
goto END
QSA_RULE_END:

  随后,回到 WordPress Permalinks 中缀相应的设置,实足正常,问题办理。




版权声明: 原创作品,允许转载,转载时请务必以超链接方式标明文章 原始来因 、作者信息和本声明。不然将追究轨则责任。

原文地址:https://www.cnblogs.com/zgqjymx/p/1975667.html