您的位置:首页 > 运维架构 > Nginx

Wordpress在Nginx中的rewrite规则

2012-11-10 20:02 363 查看
最近有童鞋问道在LNMP的环境中,怎么设置Wordpress的配置文件,现在我给一个模版:

server {

listen   80;
server_name  www.luxiaok.com;
root   /var/www/wordpress;
index  index.php index.html;

#  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;

location ~ .*\.(php|php5)  {
fastcgi_pass    127.0.0.1:9000;
fastcgi_index   index.php;
fastcgi_param   SCRIPT_NAME $fastcgi_script_name;
fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
include         fastcgi_params;
}

# 防盗链
# location ~* \.(jpg|png|swf|flv)$  {
#          valid_referers none blocked www.luxiaok.com ;
#          if ($invalid_referer) {
#          rewrite ^/ http://www.luxiaok.com/retrun.html; #          return 404;
#           }
#   }

# Rewrite规则设置
if (!-e $request_filename)  {
rewrite ^(.+)$ /index.php last;
}

}

# 域名301跳转
#
#  server {
#      server_name luxiaok.com;
#      rewrite ^/(.*) http://www.luxiaok.com/$1 permanent;
#         }
#
# By Luxiaok (C) 2012

网上有很多教程,也可以按他们的设置下。

这其实也是Nginx的一个通用的虚拟主机配置文件,装Discuz,Magento都可以使用。
本文出自 “陆小K网络工作室” 博客,请务必保留此出处http://luxiaok.blog.51cto.com/2177896/1056668
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: