guiffo
By:
guiffo

$_SERVER["REQUEST_URI"] with nginx proxy server --> get rewritten page urls

February 12, 2015 1.9k views

Hello

I am using nginx as reverse proxy server (front-end server) + apache as back-end server.

I notice I could NOT get the rewritten url output in php (like www.example.com/something/page/) with $SERVER["HTTPHOST"].$SERVER["REQUESTURI"] in nginx but it works in apache.

Note: The nginx rewrite works fine in the url but the problem is the output in php code.

I am getting such un-rewritten urls like www.example.com/index.php?a=something&b=page with $SERVER["HTTPHOST"].$SERVER["REQUESTURI"]

Can someone please help if I am doing something wrong?

This is the proxy part of my nginx

location ~ \.php$ {
     proxy_pass http://127.0.0.1:8080;
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forwarded-Proto $scheme;
}
1 comment
  • If you are using apache, you don't really need to create rules of redirection on nginx, as nginx is just a cache in this case.

1 Answer

This question was answered by @EpicCDN:

If you are using apache, you don't really need to create rules of redirection on nginx, as nginx is just a cache in this case.

View the original comment

Have another answer? Share your knowledge.