win主机使用httpd.ini完美实现wordpress伪静态

WordPress教程 11599

博客吧做了几个wordpress主题的淘宝客模板出售,由于百度对淘宝客链接不怎么友好,出于wordpress seo考虑,所以我推荐用户使用pretty link插件隐藏并跳链推广链接,但插件需要主机支持伪静态,可买模板的人很多使用win主机,设置伪静态没有linux主机简单,找到相关设置代码弄个教程。

注:使用以下方法对win空间下的wordpress设置伪静态前,请先询问主机商是否支持伪静态(IIS Rewrite 组件),这个是IIS6.0下最新的wordpress伪静态规则。

win主机wordpress伪静态规则:(以下涉及的代码采自互联网)

  1. 创建一个httpd.ini文件(创建一个txt文件,然后得命名为httpd,更改.txt的后缀为.ini),然后添加下面的代码:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    
    [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. 保存后,把httpd.ini文件上传到网站根目录,然后登陆wordpress博客后台,在设置——固定链接中的自定义结构设置url形式即可。(固定链接设置教程或相关说明请看https://www.boke8.net/wordpress-post-permalink.html

附:如果主机不支持伪静态,可以尝试下博客吧之前发布的使用404页面实现wordpress伪静态的方法https://www.boke8.net/wordpress-win-urlrewrite.html

提醒:要想使用wordpress程序建站的站长,最好还是选择linux+apache结构搭建的主机或用来搭配服务器环境,因为可以省下不少麻烦。

精品推荐: