wordpress博客win主机下实现伪静态
上次由于我意外的博客搬家,导致我从Linux主机搬到了win主机,虽然并不是完美支持,但也运行了2个多月。在刚搬过去我就发现了win主机对于wordpress博客的伪静态似乎不支持,经过1个下午的不断尝试,最终也在win主机下实现的wp博客文章页的正常伪静态。一直想写篇博客记录一下,却拖到了现在。
首先,还是强烈的建议各位准备使用wordpress博客的童鞋,尽量还是选择linux主机吧。接着就来说下我是如何完成的,但不能确保每个尝试的童鞋都能成功哈。
1、新建一个httpd.ini文件,将以下代码放添加进去,放在根目录下。
[ISAPI_Rewrite]
# Defend your computer from some worm attacks
#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# Rules to ensure that normal content gets through
RewriteRule /tag/(.*) /index\.php\?tag=$1
RewriteRule /software-files/(.*) /software-files/$1 [L]
RewriteRule /images/(.*) /images/$1 [L]
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /favicon.ico /favicon.ico [L]
# For file-based wordpress content (i.e. theme), admin, etc.
RewriteRule /wp-(.*) /wp-$1 [L]
# For normal wordpress content, via index.php
RewriteRule ^/$ /index.php [L]
RewriteRule /(.*) /index.php/$1 [L]
2、新建一个txt文本,将以下代码内容添加进去,然后另存为404.php。
<?php
$qs = $_SERVER['QUERY_STRING'];
$_SERVER['REQUEST_URI'] = substr($qs, strpos($qs, ‘:80′)+3);
$_SERVER['PATH_INFO'] = $_SERVER['REQUEST_URI'];
include(‘index.php’);
?>
3、进入wordpress后台,重新设置固定链接,保存即可。
最终,我用这种方式成功的实现了文章页的伪静态效果,但分类页还是显示有问题,只好搬回了linux主机。如果有好的解决方式,希望大家分享。
13条评论
-
分类目录显示所有文章,该怎么解决呢?
-
这个伪静态不是很懂呀。哈哈。
-
还是linux主机最适合放WP了
-
wordpress还是linux主机方便些
-
我不知道自己用的是什么主机,但是伪静态好像实现了,也许用的也是linux主机吧
-
好东西 学习了
-
好文章!收藏了!
-
顶啊 -
看来这些程序都比较难,支持博主
-
学习了一下。
-
学习了,支持
-
支持一下,谢谢分享。
在linux服务器下可以用windos操作么?