我的服务器中有很多子域名。每个子域名都有自己的 Drupal 提升规则,如以下代码所示:
server {
server_name subdomain1.website.com;
location / {
root /var/www/html/subdomain/subdomain1.website.com;
index index.php;
set $boost "";
set $boost_query "_";
if ( $request_method = GET ) {
set $boost G;
}
if ($http_cookie !~ "DRUPAL_UID") {
set $boost "${boost}D";
}
if ($query_string = "") {
set $boost "${boost}Q";
}
if ( -f $document_root/cache/normal/$host$request_uri$boost_query.html ) {
set $boost "${boost}F";
}
if ($boost = GDQF){
rewrite ^.*$ /cache/normal/$host/$request_uri$boost_query.html break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
break;
}
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/subdomain/subdomain1.website.com$fastcgi_script_name;
include fastcgi_params;
}
}
我时不时地会手动添加所有子域规则。的大小ngin.conf
已经变得太大了。
所以,
我需要一个 nginx 规则来执行以下操作:
subdomain1.website.com pointing to /var/www/html/subdomain/subdomain1.website.com
subdomain2.website.com pointing to /var/www/html/subdomain/subdomain2.website.com
subdomain3.website.com pointing to /var/www/html/subdomain/subdomain3.website.com
...等等
(这样.website.com
以后我就不需要再添加子域名的规则了。)
答案1
您需要使用类似
root /var/www/html/subdomain/$host;
fastcgi_param SCRIPT_FILENAME /var/www/html/subdomain/$host$fastcgi_script_name;