国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

Nginx下Wordpress的永久鏈接實現(301,404等)

2024-09-01 13:45:07
字體:
來源:轉載
供稿:網友

其實也是很簡單的方法,修改nginx.conf文件,加入以下內容:

復制代碼 代碼如下:


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就可以了。

以下是我的配置文件實例:

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;

#pidlogs/nginx.pid;

events {
worker_connections 1024;
}

http {
includemime.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;

sendfileon;
#tcp_nopushon;

#keepalive_timeout 0;
keepalive_timeout 65;

#gzip on;

server {
listen80;
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 ;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ /.php$ {
roothtml;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx$fastcgi_script_name;
includefastcgi_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 {
# listen8000;
# listensomename:8080;
# server_name somename alias another.alias;

# location / {
#root html;
#index index.html index.htm;
# }
#}

# HTTPS server
#
#server {
# listen443;
# server_name localhost;

# sslon;
# ssl_certificatecert.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;
# }
#}
}

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 益阳市| 和硕县| 雷波县| 临泉县| 和平区| 临武县| 东乌珠穆沁旗| 安阳市| 华坪县| 天气| 房产| 北海市| 瓮安县| 韩城市| 乌鲁木齐市| 淳安县| 杭锦旗| 轮台县| 富锦市| 青海省| 泗洪县| 三门峡市| 吉安市| 东台市| 沙洋县| 景泰县| 济南市| 榆中县| 施甸县| 黄冈市| 建阳市| 鄂伦春自治旗| 顺昌县| 安多县| 克什克腾旗| 慈溪市| 陈巴尔虎旗| 诸城市| 长沙县| 南昌县| 厦门市|