楊澤業:wordpress在Nginx/Apache/IIS中的偽靜態規則
現在,我就把怎麽配置wordpress的偽靜態規則發出來給大家一起來學習。
NGINX偽靜態規則
Nginx環境是Linux服務器裏面常見的網站配置環境,完整網站環境是Linux+Nginx+Mysql+PHP簡稱LNMP環境,他的WordPress偽靜態規則是:
location / {
try_files $uri
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
把上面的文件放置在當前網站的配置裏面,打開 nginx.conf 或者某個獨立站點的配置環境,比如 yangzeye.net.conf(不同人配置的不一樣),而我現在的是寶塔管理面板,只要在網站設置裏面的偽靜態裏面復制上面代碼保存即可。
Apache偽靜態規則
Apache環境也是Linux服務器裏面常見的網站配置環境,完整網站環境是Linux+Apache+Mysql+PHP簡稱LAMP環境,他的WordPress偽靜態規則是:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
打開網站根目錄下面的.htaccess文件,把上面的代碼復制進去,加入沒有這個文件的話,新建一個txt文本文檔,重命名為.htaccess即可。
IIS的偽靜態規則
IIS服務器是Windows系統自帶的網站服務環境,打開網站根目錄的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 /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/Apache/IIS偽靜態規則就講完了,如果還有疑問的可以在下面留言哦!
楊澤業:wordpress在Nginx/Apache/IIS中的偽靜態規則