最新公告
  • 欢迎您光临知事网软件APP资源下载站,一个优质的手机App应用商店和网站源码基地。欢迎加入永久SVIP
  • 各种web环境(IIS、apache、nginx)下的wordpress伪静态规则

    正文概述 知事网   2014-01-05 09:01:52   586

    wordpress作为世界上最流行的免费开源建站系统,WordPress 功能强大,插件众多,易于扩充功能。安装使用都非常方便。在seo方面也设计的很合理。搜索引擎友好,收录也快,排名靠前;wordpress默认的链接是动态的形式,虽然这点对于现在的搜索引擎爬虫抓取内容已经不会再构成影响了,但是伪静态的链接更具有层级结构关系,更有利于蜘蛛抓取。下面就来说说各个web系统下wordpress的伪静态规则。

    nginx

    apache环境下的wordpress伪静态规则

    <IfModulemod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} ^wp-content.*
    RewriteCond %{REQUEST_FILENAME} ^wp-admin.*
    RewriteCond %{REQUEST_FILENAME} ^wp-include.*
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    新建一个.htaccess文件并将以上代码写入.htaccess文件中,上传至wordpress站点的根目录中。

    [doloadbtn title=”.htaccess文件下载” href=”https://www.liuzhishi.com/Download/htaccess.rar” target=”_blank”]下载.htaccess文件[/doloadbtn]

    IIS(windows)环境下的wordpress伪静态规则(方法一):

    打开站点根目录下的web.config文件并加入以下代码:

    <rewrite>
    <rules>
    <rulename="Main Rule"stopProcessing="true">
    <matchurl=".*"/>
    <conditionslogicalGrouping="MatchAll">
    <addinput="{REQUEST_FILENAME}"matchType="IsFile"negate="true"/>
    <addinput="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true"/>
    </conditions>
    <actiontype="Rewrite"url="index.php/{R:0}"/>
    </rule>
    </rules>
    </rewrite>

    IIS(windows)环境下的wordpress伪静态规则(方法二):

    新建一个httpd.ini文件并加入以下代码,上传至wordpress站点根目录中:

    [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 /sitemap.xml.gz /sitemap.xml.gz [L]
    RewriteRule /robots.txt /robots.txt [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]

    [doloadbtn title=”httpd.ini下载” href=”https://www.liuzhishi.com/Download/httpd.rar” target=”_blank”]下载httpd.ini文件[/doloadbtn]

    nginx环境下的wordpress伪静态方法:

    location / {
    index index.html index.php;
    if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
    }
    if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
    }
    if (!-f $request_filename){
    rewrite (.*) /index.php;
    }
    }

    将以上代码加入到nginx.conf文件的Server段内。以上就是所有web环境下的wordpress伪静态规则。当然,需要添加.htaccess和httpd.ini、nginx.conf的方法适用独立服务器或VPS。wordpress在虚拟主机的环境下设置伪静态可以用另一种方法。


    知事网 » 各种web环境(IIS、apache、nginx)下的wordpress伪静态规则

    发表评论

    还没有评论,快来抢沙发吧!

    [!--temp.right--]
    请选择支付方式
    ×
    余额支付
    ×
    微信扫码支付 0 元