Warning: Declaration of c2c_ConfigureSMTP::options_page_description() should be compatible with C2C_Plugin_023::options_page_description($localized_heading_text = '') in /home/mslandymdsol1agnid/wwwroot/wp-content/plugins/configure-smtp/configure-smtp.php on line 47 wordpress在win主机开启伪静态启用Rewrite模块 | 迷失的世界
当前位置: 首页 > 网站相关 > 正文

wordpress在win主机开启伪静态启用Rewrite模块

伪静态通过【win主机 伪静态 】

最近使用wordpress建立了这个博客,首先国外的程序环境要求和国内的好多差异,采用ISAPI_Rewrite后怎么也无法静态化,静态化成 功后网址中必须带有index.php,本来无法去掉也无所谓;当文章翻页的时候发现了问题,主页的分页到第二页第三页….都无法打开,原因是地址中 竟然多了一个index.php(例如:index.php/index.php/pag这样了,url完全错误了),许多人说环境问题,无奈下开始考虑 重新来考虑静态问题,分析思路采用Discuz论坛哪种伪静态方式比较不错,那么为什么discuz可以,却在wordpress不可以呢,功夫不负有新 人,昨天晚上调试成功了,和大家分享一下。

首先你的服务器加载了ISAPI_Rewrite,Discuz如果您正在使用伪静态,那么就不要考虑再次加载了,在wordpress官方许多人提出了 需要单独加载专用的Rewrite,其实不需要,在国内的文章copy太严重了,找了一天,发现重复的起码有9.6成都同出一辄,没有一点正确性,不能使 用,无奈之下去国外搜索到后,建立了httpd.ini,网站成功完成了静态,永久链接规则也可以自行随意根据喜好设置,这是国内那些描述中还没有做到 的,本站就是采用的这个规则,在永久链接内也可以随意修改自己的喜好网址样式,同样seo目的也达到了,如果您在使用wordpress的时候还在被前边 描述的问题困扰,那么赶快行动吧。
备注:
1、在你使用ISAPI_Rewrite后,无需再使用cos-html-cache静态生成插件,因为没有这个必要了。
2、ISAPI_Rewrite国外网址:http://www.basilv.com/psd/blog/2 … dpress-20-under-iis
规则如下:

 [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 /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]

安装说明:
1. 将Rewrite.dll拷贝到c:\Rewrite.dll(也可以拷贝到C:\WINDOWS目录内,位置根据喜好可以自由放置);
2. 在IIS的Isapi上添加这个筛选器, 筛选器名称Rewrite,可执行文件选择Rewrite.dll;
3. 重新启动IIS,成功后会有如下显示:

4. httpd.ini 是配置文件,如果您了解Rewrite 规则,可以直接对其进行编辑;
5. 默认规则为wordpress专用,其他PHP程序伪静态无法使用;
备注:在前三项成功完成后,将httpd.ini传送到网站跟目录就完成了伪静态环境搭建,下边开始进入后台,设置永久链接采用自定义方式,代码可以参考官方:http://codex.wordpress.org/Using_Permalinks,设置您喜欢的显示方式即可[例子:/%category%/%postname%.html 含义是按照分类目录名称/内容页名称.html方式,增加html就是大家喜欢看到的静态标识 ]伪静态就这样建立完成了;

第二个方法:

Windows主机下安装WordPress程序,默认实现不了像Linux系统环境下的完美伪静态,这也是Windows主机用户安装WordPress程序最为头疼的地方,这里WPYOU把相关方法分享给大家:

方法1:
1.1 首先,主机装Rewrite 组件,现在国内很多Windows主机默认就装这个组件了。最好做伪静态的时候先问下你的空间商。

1.2 主机启用了Rewrite模块后,剩下的只需要一个httpd.ini就能解决问题了。

httpd.ini是指wordpress程序在windows虚拟主机上的伪静态设置。下面就贴出WP伪静态的httpd.ini代码:

[ISAPI_Rewrite]
# 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 /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]

1.3 把httpd.ini直接上传到网站根目录即可实现。

总结:这种方式是实现Windows主机的伪静态最简单快捷的方法。

方法2:
如果方法1 中代码不能实现,可以试下下面这段代码(同样是放到httpd.ini中,然后上传到网站根目录):

[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
# wordpress 伪静态规则
# For tag(中文标签以及标签翻页的规则)
RewriteRule /tag/(.*)/page/(\d+)$ /index\.php\?tag=$1&paged=$2
RewriteRule /tag/(.+)$ /index\.php\?tag=$1
# For category(中文分类以及分类翻页的规则)
RewriteRule /category/(.*)/page/(\d+)$ /index\.php\?category_name=$1&paged=$2
RewriteRule /category/(.*) /index\.php\?category_name=$1
# For sitemapxml
RewriteRule /sitemap.xml /sitemap.xml [L]
RewriteRule /sitemap.html /sitemap.html [L]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.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]


分享到:

本文固定链接: http://www.msland.cn/wordpress-win-rewrite.html | 迷失的世界

该日志由 Zero 于2012年05月27日发表在 网站相关 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。
原创文章转载请注明: wordpress在win主机开启伪静态启用Rewrite模块 | 迷失的世界
关键字: , , ,

wordpress在win主机开启伪静态启用Rewrite模块:目前有4 条留言

  1. 板凳
    xiaomu Internet Explorer Windows :

    按照第二种方法做了之后,发现地址中的index.php是去掉了,但是后台登陆不了了,打开是404页面 求解

    2012-09-13 下午 11:59
    • Zero Google Chrome Windows :

      这个方法其实有很多不好的地方,不推荐你用。还是换空间吧!

      2012-09-25 上午 3:01
  2. 沙发
    混乱羽翼 360 Browser Windows :

    额,现在已经搞定了么?为什么地址还是带index.php的哇

    2012-05-28 下午 7:42
    • zero Mozilla Firefox Windows :

      主机是我朋友的,,方法找到了。我转发过来就是让他照着搞的。这家伙也没动静了。想还个l主机算了。。w主机太悲剧了!~~对了你加我qq 那个vip等级问题请教下你!~

      2012-05-28 下午 7:47

发表评论

您必须 [ 登录 ] 才能发表留言!