飞六网

 找回密码
 飞六网用户注册邮箱验证
搜索
热搜: 系统 工具
查看: 5491|回复: 0
打印 上一主题 下一主题

分享:windows主机wordpress程序伪静态设置方法

[复制链接]

461

主题

479

帖子

1854

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1854
跳转到指定楼层
楼主
发表于 2013-8-6 11:25:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
[飞六网]-[网站建设]:wordpress是世界上最好用的博客程序.wordpress功能强大,主题风格多样,是很多站长的最佳选择,wordpress默认是动态地址页面,这样不利于搜索引擎收录.
对于使用windows主机来说实现wordpress程序伪静态的方法常见有以下几种:
第一种方法:用404.php实现伪静态。

1、新建一个404.txt文档,将以下代码复制进去:

header(“HTTP/1.1 200 OK”);
     $ori_qs = $_SERVER['QUERY_STRING'];
     $pattern = ‘/[^;]+;[^:]+://[^/]+(/[^?]*)(?:?(.*))?/i’;
     preg_match($pattern, $ori_qs, $matches);
     $_SERVER['PATH_INFO'] = $matches[1] . ‘?’ . $matches[2];
     $_SERVER['REQUEST_URI'] = $_SERVER['PATH_INFO'];
     $query_args = explode(‘&’, $matches[2]);
     unset($_GET);
     foreach ($query_args as $arg)
     {
         $the_arg = explode(‘=’, $arg);
         $_GET[$the_arg[0]] = $the_arg[1];
     }
     include(‘index.php’);
     ?>

复制进去后,点击另存为,保存为404.php.
2、然后进入WP后台,【设置】–【固定连接】里面,先把固定连接选择自定义,设置成/%post_id%.html。

3、上传下面的404.php页面到网站根目录下,然后在虚拟主机控制面板里面修改404跳转页面为刚才上传的404.php,这样就可以实现伪静态了。

第三步是个重点,下面看图。
(1)、打开Internet 信息服务(IIS)管理器


(2)、找到自己的网站,右键属性。
 
(3)、找到 找到404页面

(4)、编辑

到此 已基本可以解决伪静态,
第二种方法
首先你的主机(或者VPS)要装Rewrite 组件,现在国内很多WINDOWS主机都有装这个了,但是很多主机商,没有开启,所以你得让他给你开好。
使用方法:新建httd.ini文件,复制以下代码,保存。直接上传到网站的根目录。然后去WP后台设置固定连接:/%post_id%.html
然后在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]

但是,有时候会出现这样那样的问题

如果用了第二种方法导致百度地图链接打不开请添加以下两句代码:

RewriteRule /sitemap.html /sitemap.html [L]
RewriteRule /sitemap_baidu.xml /sitemap_baidu.xml [L]

第三种方式:另外一个比较具体的写法,如果用第二个有问题,可以尝试这个
[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]
这种,就是万能的了。
以上几步做完就OK了~。

如果是自己的vps,而没有 IIS Rewrite 组件,那就得自己配置一个了。
下面是配置教程:
(1)、将下载的 IIS Rewrite (ISAPI_Rewrite3.rar)组件解压,放到适当的目录(如C:ISAPI_Rewrite3)下。
iis rewrite

(2)、解压完毕后,您需要给C:ISAPI_Rewrite3目录加上adms,system全部的权限、Users读与运行的权限,如果您不加上Users的权限,就会造成IIS无法启动。

(3)、设置好权限后,在 IIS 管理器里选择网站,右键选择“属性”,如下图所示:


(4)、然后选择ISAPI筛选器,然后点击“添加” 选型卡 如下图:
iis2

(5)、点击添加选项卡之后,在筛选器名称填写iiswrite,可执行文件选取:C:ISAPI_Rewrite3ISAPI_Rewrite.dll ,也就是解压isapi_rewrite 3的文件夹路径。
(6)、点击“确定” 按钮。

(7)、重新启动 IIS 。

(8)、点击确定

(9)、重新选择网站 => 右键“属性”=> “ISAPI 筛选器”,如果看到状态为向上的绿色箭头,就说明 IISRewrite 模块安装成功了。


到此你就可以成功在win主机下完成伪静态了。
回复

使用道具 举报

本版积分规则

Archiver|手机版|小黑屋|飞六网 ( 粤ICP备12045999号 )

GMT+8, 2024-4-19 20:30 , Processed in 0.073963 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表