nginx 重写 url 使用 hashbang 删除子文件夹?

nginx rewrite url removing subfolder with hashbang?

url是这样的

site.com/#/fr/welcome/

我想重写(并删除)url /fr/ 部分而不影响任何其他内容

/fr/ 和 /welcome/ 一开始就不是真正的文件夹。我所在的开发人员目前正在使用 Angular.

我不知道该怎么做,我实际上已经搜索过类似的线程,但这些线程中的所有内容要么没有执行任何操作,要么页面加载失败。

有人可以帮忙吗?谢谢

这是我当前的 Nginx 配置:

server {


 listen 80;

server_name www.site.co site.co;
root /home/forge/site.co/public;

# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;

index index.html index.htm index.php;

charset utf-8;

if (!-d $request_filename) {
    rewrite ^/(.+)/$ / permanent;
}

location / {
    try_files $uri $uri/ /fr/index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log on;
error_log  /var/log/nginx/site.co-error.log error;

error_page 404 /index.php;

您在 nginx 中对此无能为力,因为浏览器不会在 hashbang 之后将数据发送到服务器。

参见:How to get Url Hash (#) from server side