gpt4 book ai didi

Nginx下Wordpress的永久链接实现(301,404等)

转载 作者:qq735679552 更新时间:2022-09-29 22:32:09 30 4
gpt4 key购买 nike

CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.

这篇CFSDN的博客文章Nginx下Wordpress的永久链接实现(301,404等)由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.

其实也是很简单的方法,修改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,

#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下Wordpress的永久链接实现(301,404等)的文章就讲到这里了,如果你想了解更多关于Nginx下Wordpress的永久链接实现(301,404等)的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com