我正在尝试通过以下重写将工作从example.com/a/a23uy324
重写为example.com/index.php/render?id=a23uy324
:
location ~ ^/a {
rewrite ^/a/(.*)$ https://example.com/index.php/render?id=$1 break;
}
,但任何规则,例如last
,break
或permanent
-均无效。网站仍然重定向到PHP脚本。请告知。
这里是完整的配置:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name example.com www.example.com;
ssl_certificate /var/www/example.com/certificates/certificate.crt;
ssl_certificate_key /var/www/example.com/certificates/private.key;
root /var/www/example.com/public_html;
index index.php index.html index.htm;
#works
location ~ ^/a {
rewrite ^/a/(.*)$ https://example.com/index.php/render?id=$1 break;
}
location ~* ^/(assets|files|robots\.txt) { }
location / {
try_files $uri $uri/ /index.php?/$request_uri;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/example.com/public_html$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location ~* .(jpg|jpeg|png|gif|ico|css|js)$ {
expires 7d;
}
}