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 截止呼应的设置,十足正常,结果打点。
版权声明:
原创作品,允许转载,转载时请务必以超链接体式款式标明文章 原始来因 、作者信息和本声明。否则将追究执法责任。