伪静态是一种代替全静态与动态文件比较好的一个东西,下面我来给大家介绍在Windows2003 IIS6中WordPress伪静态配置过程,有需要的朋友可参考。
网站根目录下新建立一个httpd.ini文件,用记事本或是emeditor打开,规则写在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个txt文档,再复制虚横线之下的代码内容,粘贴到txt文档里面保存后,再修改文档文件名为httpd.ini就可以
注意:要给dll所在的目录加上IIS_WPG组的写入权限,否则无法加载对应dll文件。
(1)中文的tag无法访问
解决办法:需要使用ISAPI_Rewrite来写一条规则:
RewriteRule /tag/(.*) /index.php?tag=$1(2)含有中文的网址也是不能访问的
3.安装ISAPI_Rewrite
网站根目录下新建立一个httpd.ini文件,用记事本或是emeditor打开,规则写在httpd.ini里,如下:
[ISAPI_Rewrite] # 3600 = 1 hour CacheClockRate 3600 RepeatLimit 32 RewriteRule /tag/(.*)/ /index.php?tag=$1
现在中文tag是能访问了,但是还是存在问题。
存在的问题:
(1) tag页面的文章超过1页,翻页时都不能访问
解决办法:
修改这条规则为:
RewriteRule /tag/[^/]+)/([^/]+)/?([0-9]+)?/ /index.php?tag=$1&paged=$3 [L]
但是修改之后中文tag又不能访问了,别担心,接着看下一步。
4.修改wp-include中的classes.php
继续修改第三步中的问题,因为修改Rewrite规则之后中文tag还是不能访问,含有中文的网址也是不能访问。最好使用专门的PHP编辑器工具,如EditPlus,我用的是emeditor。
修改WP-include中的classes.php
原代码:
$pathinfo = $_SERVER['PATH_INFO'];
替换为:
$pathinfo = mb_convert_encoding($_SERVER['PATH_INFO'], "UTF-8", "GBK");
原代码:
$req_uri = $_SERVER['REQUEST_URI'];
替换为:
$req_uri = mb_convert_encoding($_SERVER['REQUEST_URI'], "UTF-8", "GBK");
修改后,保存下,然后将保存后的classes.php文件上传并覆盖原文件即可,这里需要注意文件保存格式
接着我们需要在WordPress网站后台配置了,具体如下图操作
如下图所示,进入wordpress博客管理后台:
1。点菜单紧右边的“设置”
wordpress
<a href=伪静态设置" border="0" alt="wordpress伪静态设置" src="http://xxx.net/2013/03/26/20130326064447904.png" width="156" height="179" />
点选其下的”固定链接”或者“永久链接”(Permalinks)
点选“自定义结构”,并输入你的自定义结构,何苦呢一般都是这样子写的“/%postname%.html“
这样子的话,如果是用中文题目,需要为每篇文章手动设置一下永久链接,否则中文会被转变成一些乱码。
永久链接使用“/%postname%.html”的结构以来层次比较简单,二来也便于在永久地址用加入一些关键词的拼音之类的,更加有利于seo。
点页面下方的按钮“保存更改”
此时在 WordPress 的根目录自动生成里一 .htaccess 文件,内容大体如下:
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ – [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>