免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1145 | 回复: 0
打印 上一主题 下一主题

Linux下给WordPress配置伪静态 [复制链接]

论坛徽章:
1
15-16赛季CBA联赛之北控
日期:2022-03-04 22:35:50
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-05-24 22:38 |只看该作者 |倒序浏览

来源:
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 进行相应的设置,一切正常,问题解决。


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/31/showart_704912.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP