0

I hope you can help me on the following matter.

I have NGINX Running and want to forward to .html (virtual pages) to index.php?view=$args without changing the URL, which is shown in the Browser Address Bar (REQUEST URI)

I tried it several times now but each time I go to: example.com/meldung.html NGINX changes the Browser URL to: example.com/index.php?view=Meldung but that is not what I want.

example.com/meldung.html should be internally routed to the index.php?view=$1 but not outside what the user sees.

        listen 80;
        root /var/www/example.com;
        index index.html index.htm index.php;

        server_name example.com www.example.com
        index index.html index.htm index.php;
        access_log /var/log/nginx/example.com_access.log;
        error_log /var/log/nginx/example.com.io_error.log;
        set $skip_cache 0;
        # POST requests and URLs with a query string should always go to PHP
        if ($request_method = POST) {
        set $skip_cache 1;
        }

        if ($query_string != "") {
        set $skip_cache 1;
        }
        location / {
                try_files $uri $uri/ =404;
                satisfy all;

                if (!-f $request_filename) {
                        rewrite ^(.*)\.html$ /index.php?view=$1 last;
                }
        }
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php5.6-fpm.sock;
                fastcgi_cache_bypass $skip_cache;
                fastcgi_no_cache $skip_cache;
        }

On Apache it has worked properly:

RewriteRule ^(.*).html$ index.php?view=$1 [L,NC]

but not on NGINX

Berlinux
  • 1
  • 1

0 Answers0