[英]Nginx Rewrite Rule with PHP not working properly
我有這樣的網址結構:
並希望將其重寫為:
為此,我嘗試了大約1000種組合,基本上全部歸結為以下代碼:
location /overview/ {
rewrite ^/overview/(.+)$ /triggers/overview.php?technician=$1 last;
}
我正在使用Ajenti,php-fpm 7和nginx。
有任何想法嗎?
另外這里是整個.conf文件的上下文:
server {
listen *:80;
listen *:443 ssl;
ssl_certificate /certificates/fullchain.pem;
ssl_certificate_key /certificates/privkey.pem;
server_name subdomain.domain.com;
access_log /var/log/nginx/technicians.access.log;
error_log /var/log/nginx/technicians.error.log;
root /srv/technicians;
index index.html index.htm index.php;
# ACME challenge for letsencrypt
location ^~ /.well-known/acme-challenge {
alias /var/www/letsencrypt.sh;
}
# rewrite overview
rewrite_log on;
location /overview/ {
rewrite ^/overview/(.+)$ /triggers/overview.php?technician=$1 last;
}
# rewrite urls of requirements
rewrite ^/requirements/(.*)$ /requirements/$1.html last;
location ~ [^/]\.php(/|$) {
fastcgi_index index.php;
include fcgi.conf;
fastcgi_pass unix:/var/run/ajenti-v-php7.0-fcgi-technicians-php7.0-fcgi-0.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
我自己找到了解決方案:配置正確,我要做的就是確保nginx確實重新啟動。
在Ajenti中,這無法通過UI進行,因此我通過nginx -s reload
嘗試,該方法有效。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.