wordpress默認的鏈接是動態(tài)的形式,,雖然這點對于現(xiàn)在的搜索引擎爬蟲抓取內容已經不會再構成影響了,但是偽靜態(tài)的鏈接更具有層級結構關系,,更有利于蜘蛛抓取,。下面就說說各個web系統(tǒng)下wordpress的偽靜態(tài)規(guī)則。
apache環(huán)境下的wordpress偽靜態(tài)規(guī)則:
RewriteEngine OnRewritebase /RewriteRule ^index\.php$ - [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule . /index.php [L]
新建一個.htaccess文件并將以上代碼寫入.htaccess文件中,,上傳至wordpress站點的根目錄中,。
IIS環(huán)境下的wordpress偽靜態(tài)規(guī)則(方法一):
打開站點根目錄下的web.config文件并加入以下代碼:
<rewrite> <rules> <rule name="Main Rule" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php/{R:0}" /> </rule> </rules></rewrite>
IIS環(huán)境下的wordpress偽靜態(tài)規(guī)則(方法二):
新建一個httpd.ini文件并加入以下代碼:
[ISAPI_Rewrite]# Defend your computer from some worm attacks#RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]# 3600 = 1 hourCacheClockRate 3600RepeatLimit 32# Protect httpd.ini and httpd.parse.errors files# from accessing through HTTP# Rules to ensure that normal content gets throughRewriteRule ^/$ /index.php [L]RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule /(.*) /index.php/$1 [L]
上傳至wordpress站點根目錄。
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段內,。
以上就是所有web環(huán)境下的wordpress偽靜態(tài)規(guī)則,。