Nginx下Wordpress的永久鏈接實(shí)現(xiàn)(301,404等)
其實(shí)也是很簡(jiǎn)單的方法,修改nginx.conf文件,加入以下內(nèi)容:
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;
}
}
重啟nginx就可以了。
以下是我的配置文件實(shí)例:
www# cat nginx.conf
user www www;
worker_processes 10;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] $request ‘
# ‘”$status” $body_bytes_sent “$http_referer” ‘
# ‘”$http_user_agent” “$http_x_forwarded_for”‘;
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /usr/local/www/nginx;
index index.php index.html index.htm;
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;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
- Nginx實(shí)現(xiàn)404頁面的方法小結(jié)
- Nginx中404頁面的配置及AJAX請(qǐng)求返回404頁面的方法
- Nginx+CI框架出現(xiàn)404錯(cuò)誤怎么解決
- Nginx服務(wù)器中配置404錯(cuò)誤頁面時(shí)一些值得注意的地方
- 一個(gè)等號(hào)引發(fā)的血案(談Nginx正確的404配置)
- Nginx中定義404頁面并且返回404狀態(tài)碼的正確方法
- PHP統(tǒng)計(jì)nginx訪問日志中的搜索引擎抓取404鏈接頁面路徑
- NGINX下配置404錯(cuò)誤頁面的方法分享
- 為Nginx自定義404,502錯(cuò)誤頁面的方法
- NGINX服務(wù)器配置404錯(cuò)誤頁面轉(zhuǎn)向的方法
相關(guān)文章
windows系統(tǒng)安裝配置nginx環(huán)境
這篇文章介紹了windows系統(tǒng)安裝配置nginx環(huán)境的方法,對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06Nginx+Tomcat+Https 服務(wù)器負(fù)載均衡配置實(shí)踐方案詳解
這篇文章主要介紹了Nginx+Tomcat+Https 服務(wù)器負(fù)載均衡配置實(shí)踐方案的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09基于nginx實(shí)現(xiàn)上游服務(wù)器動(dòng)態(tài)自動(dòng)上下線無需reload的實(shí)現(xiàn)方法
這篇文章主要介紹了基于nginx實(shí)現(xiàn)上游服務(wù)器動(dòng)態(tài)自動(dòng)上下線無需reload,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-02-02