wordpress最新偽靜態(tài)規(guī)則
wordpress默認(rèn)的鏈接是動(dòng)態(tài)的形式,大家都喜歡搞搞SEO,變換下鏈接地址,于是wordpress偽靜態(tài)就登場(chǎng)了。偽靜態(tài)的鏈接更具有層級(jí)結(jié)構(gòu)關(guān)系,更有利于蜘蛛抓取,不同的web環(huán)境偽靜態(tài)鏈接規(guī)則也不一樣,整理了幾種,方便大家參考。 apache環(huán)境下的wordpress偽靜態(tài)規(guī)則
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
新建一個(gè).htaccess文件并將以上代碼寫入.htaccess文件中,上傳至wordpress站點(diǎn)的根目錄中。 IIS環(huán)境下的wordpress偽靜態(tài)規(guī)則 方法1、打開站點(diǎn)根目錄下的web.config文件并加入以下代碼:
<rulename="Main Rule"stopProcessing="true">
<matchurl=".*"/>
<conditionslogicalGrouping="MatchAll">
<addinput="{REQUEST_FILENAME}"matchType="IsFile"negate="true"/>
<addinput="{REQUEST_FILENAME}"matchType="IsDirectory"negate="true"/>
<actiontype="Rewrite"url="index.php/{R:0}"/>
方法2、新建一個(gè)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站點(diǎn)根目錄。
nginx環(huán)境下的wordpress偽靜態(tài)方法
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段內(nèi)。 這是目前比較流行的幾種web配置的偽靜態(tài)規(guī)則。