Nginx has redirect loop when trying to redirect to https is my site’s url.

It has a redirect loop on the line where it redirects to https.

Any fix?

Also how would I hide the PHP extension?

I have nginx 1.9.3 on ubuntu.

server {
	listen 80 default_server;
	root /var/www/html;

	# Add index.php to the list if you are using PHP
	index index.php;

	return 301$request_uri; # Where it loops
	error_page 500 /500.html;
	error_page 404 /404.php;

	location / {
		# First attempt to serve request as file, then
		# as directory, then fall back to displaying a 404.
		try_files $uri $uri/ =404;
		#htacess stuff

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


return 301$request_uri; to return 301 https://$server_name$request_uri;

And where is your 443 listen? You can’t point to https if you didn’t set it up :)