【发布时间】:2015-01-06 03:14:18
【问题描述】:
我们将在我们的网站上引入一个使用 Laravel 框架的新部分。它被放置在一个子目录中,例如/newsection。我应该如何配置 nginx.conf 而不与我之前的重写规则产生任何冲突。
这是我目前的nginx.conf
server {
listen 80;
server_name localhost www.website.com;
root /home/www/website;
index index.html index.php;
location /newsection/ {
rewrite ^/ /newsection/public/index.php last;
# this is my attempt at it
}
location / {
try_files $uri $uri/ @rewrite;
}
location /php-status {
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
location @rewrite {
rewrite ^/([\w_-]+)/?$ /index.php?page=$1 last;
rewrite ^/([\w_-]+)/([\w_-]+)/?$ /index.php?page=$1&slug=$2 last;
rewrite ^/([\w_-]+)/([\w_-]+)/([\w_-]+)/?$ /index.php?page=$1&slug=$2&pagination=$3 last;
}
include php.conf;
}
【问题讨论】: