使用服务器配置在Nginx中进行URL重写

问题描述

我有一个Nginx服务器。

我想在每个Web请求上重写一个URL。

因为我的访客知道URl,但我将其存储在另一个位置。

所以我做到了:

#Names a server and declares the listening port
server {
  listen 80;
  server_name 10.37.1.85 images-raw.fn.fr;

  #Configures the publicly served root directory
  #Configures the index file to be served
  root /web/images-raw.fnaim.fr;
      index index.html index.htm index.PHP;

    location / {
rewrite_log on;
    rewrite ^images1/img([0-9]*)/([\w/-_]*).(jpg|JPG)$ /get_image.pp.PHP?name=/$2 last;

        try_files $uri $uri/ =404;
    }

    location ~ \.PHP$ {
        include snippets/fastcgi-PHP.conf;
        fastcgi_pass unix:/var/run/PHP5-fpm.sock;
    }

但是我的重定向根本不起作用。

我要写什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)