我有以下设置 - 某些软件的生产版本;
location @myradio {
rewrite ^/myradio/([^/]+)/([^/]+)/? /myradio/index.php?module=$1&action=$2 last;
rewrite ^/myradio/([^/]+)/? /myradio/index.php?module=$1 last;
}
location /myradio {
alias /usr/local/www/myradio/src/Public;
try_files $uri $uri/ @myradio;
location ~ \.php {
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php5-fpm;
}
}
和几个开发版本 - 还有myradio-lordaro等等。
location @myradiodev {
rewrite ^/myradio-([^/]+)/([^/]+)/([^/]+)/? /myradio-$1/index.php?module=$2&action=$3 last;
rewrite ^/myradio-([^/]+)/([^/]+)/? /myradio-$1/index.php?module=$2 last;
}
location /myradio-dev {
alias /usr/local/www/myradio-dev/src/Public;
try_files $uri $uri/ @myradiodev;
location ~ \.php {
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass php5-fpm;
}
}
这两种工作都很好,但是多次复制相同的/ myradio- *配置似乎效率低下,我觉得我可以做得更好。
是否可以将开发配置概括为使用正则表达式将nginx重定向到正确位置的配置? @myradiodev成功用于所有开发版本,所以我不相信这是问题,但我自己尝试这样做只会导致各种403或404错误,并且不清楚nginx试图访问的位置。< / p>
[关于如何清理它的其他建议赞赏(最初是从apache配置转换而来)]