各種web環境下的wordpress僞靜態規則

wordpress作爲世界上最流行的免費建站系統,在seo方面也設計的很合理。wordpress默認的鏈接是動態的形式,雖然這點對於現在的搜索引擎爬蟲抓取內容已經不會再構成影響了,但是僞靜態的鏈接更具有層級結構關係,更有利於蜘蛛抓取。下面小V就以v7v3.com爲例來說說各個web系統下wordpress的僞靜態規則。

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站點的根目錄中。

IIS環境下的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環境下的wordpress僞靜態規則(方法二):

新建一個httpd.ini文件並加入以下代碼:

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

上傳至wordpress站點根目錄。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僞靜態規則。

http://v7v3.com/wpjiaocheng/201307146.html​


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章