wordpress做爲世界上最流行的免費建站系統,在seo方面也設計的很合理。wordpress默認的連接是動態的形式,雖然這點對於如今的搜索引擎爬蟲抓取內容已經不會再構成影響了,可是僞靜態的連接更具備層級結構關係,更有利於蜘蛛抓取。下面小V就以v7v3.com爲例來講說各個web系統下wordpress的僞靜態規則。 php
apache環境下的wordpress僞靜態規則: html
<IfModulemod_rewrite.c> nginx
RewriteEngine On web
RewriteBase / apache
RewriteCond %{REQUEST_FILENAME} ^wp-content.* wordpress
RewriteCond %{REQUEST_FILENAME} ^wp-admin.* 搜索引擎
RewriteCond %{REQUEST_FILENAME} ^wp-include.* url
RewriteCond %{REQUEST_FILENAME} !-f 設計
RewriteCond %{REQUEST_FILENAME} !-d orm
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僞靜態規則。