【发布时间】:2014-06-11 16:17:15
【问题描述】:
我设置了通配符域,我正在尝试使其重写规则适用于一个子域而不是另一个子域,也不适用于主域。
server{
listen 80 default_server;
server_name _;
root /usr/share/nginx/html/$http_host;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
include /usr/share/nginx/conf/mission13.io.conf;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
如您所见,我将mission13.io.conf 包含在我的重写位置中,我尝试了一些不同的方法,但没有任何效果,例如:
rewrite ^http://sub.mission13.io/(.+)/(.+)$ /index.php?page=$1&action=$2&ajax=0;
我也试过这个:
location sub.missison13.io/ {
rewrite ^(.+)/(.+)$ /index.php?page=$1&action=$2&ajax=0;
}
这两种方法都不起作用。我该怎么做?
【问题讨论】:
-
您是否尝试将所有请求重写为sub.mission13.io?
标签: nginx url-rewriting rewrite subdomain wildcard