wordpress伪静态规则大全及设置方法
云主機(jī)或vps推薦使用寶塔面板搭建服務(wù)器環(huán)境,內(nèi)置了wordpress的偽靜態(tài)規(guī)則,直接選擇即可,使用十分簡單。
以下給大家分享nginx,apache,iis下的wordpress偽靜態(tài)規(guī)則
Nginx 偽靜態(tài)規(guī)則
打開 nginx.conf 或者某個站點的配置環(huán)境,比如 fengjunzi.com.conf(不同人配置的不一樣),在 server { } 大括號里面添加下面的代碼:
[php]location / {
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;
}
}
[/php]
保存,重啟 Nginx 即可。
Apache 偽靜態(tài)規(guī)則
新建一個 htaccess.txt 文件,添加下面的代碼:
[php]<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>[/php]
上傳到 WordPress 站點的根目錄,重命名為 .htaccess 即可。
IIS 偽靜態(tài)規(guī)則
新建一個 txt 文件,將下面的代碼添加到文件中:
[php]
[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][/php]
然后另存為 httpd.ini 文件,上傳到 WordPress 站點的根目錄即可。
本文轉(zhuǎn)自:https://www.ewuxiu.com/3330.html
總結(jié)
以上是生活随笔為你收集整理的wordpress伪静态规则大全及设置方法的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Nginx禁止IP访问和未绑定域名访问
- 下一篇: 浅谈CSRF攻击方式【转】