NGINX should not change the URL in the Browser Address Bar

fr flag

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: NGINX changes the Browser URL to: but that is not what I want. should be internally routed to the index.php?view=$1 but not outside what the user sees.

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

        index index.html index.htm index.php;
        access_log /var/log/nginx/example.com_access.log;
        error_log /var/log/nginx/;
        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

Ivan Shatsky avatar
gr flag
Check your request with `curl`. Is it a redirect coming from your PHP-FPM upstream?
djdomi avatar
za flag
why is index double inside the configuration?

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.