折腾了一晚上 nginx ,发现一个 nginx 配置需求实现不了
1 、 http://www.xxx.com/blog/.* 正常请求 /wwwdata/xxx/blog 下的一个 wordpress
2 、 http://www.xxx.com/ 302 到 http://www.xxx.com/blog/
3 、其余请求 http://www.xxx.com/.* 都 302 到另外一个 URL http://www.aaa.com/
目前的配置是
server
{
listen 80;
server_name www.xxx.com;
index index.php;
root /wwwdata/xxx;
location = /
{
rewrite . http://www.xxx.com/blog/ redirect;
}
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
}
}
第一和第二两点都好操作,但当我尝试加入 location ^~ / 貌似所有请求都进去这个 location 了, php 也不解析。
nginx 自学的也没太懂,请问各位大牛这个该咋写?
1 、 http://www.xxx.com/blog/.* 正常请求 /wwwdata/xxx/blog 下的一个 wordpress
2 、 http://www.xxx.com/ 302 到 http://www.xxx.com/blog/
3 、其余请求 http://www.xxx.com/.* 都 302 到另外一个 URL http://www.aaa.com/
目前的配置是
server
{
listen 80;
server_name www.xxx.com;
index index.php;
root /wwwdata/xxx;
location = /
{
rewrite . http://www.xxx.com/blog/ redirect;
}
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
fastcgi_index index.php;
}
}
第一和第二两点都好操作,但当我尝试加入 location ^~ / 貌似所有请求都进去这个 location 了, php 也不解析。
nginx 自学的也没太懂,请问各位大牛这个该咋写?