Nginx Issue
-
So, my sites live, and I've transferred everything over, site is available on http://35hz.co.uk
However the old address was http://www.35hz.co.uk/forum/
So I need to redirect both forum to root, and www to non www. I've got this in my server block, but it's saying page not found.
server { listen 80; server_name www.35hz.co.uk; rewrite ^ $scheme://35hz.co.uk$request_uri? permanent; }
But I'm pretty lost. Nothing I change works.
If anyone could do me a solid and help me work this out, I'd be eternally grateful.
-
Paging resident nginx expert, @julian
-
@psychobunny I'm hoping going into DNS in Digital OCean and creating another record for www.35hz.co.uk will help. The funny thing is, my iPad is still showing my old website.
-
This might help you
-
I don't know enough about nginx internals to be confident enough to write a single server block to do both of those, but try this:
server { listen 80; server_name www.35hz.co.uk; return 302 https://35hz.co.uk$request_uri; }
And possible for the
/forum
redirect...location ^~ /forum(.*) { return 302 $scheme://$http_host/$1$is_args$query_string; }
YMMV?
When it starts working, switch those 302s to 301s. Then Google will know to transfer requests from one to the other.
-
@julian I think the issue could be further back than this, as www.35hz.co.uk gets server not found, not the nginx landing page...
I've created a record in Digital OCean for it, but it's made no difference, so not sure where to go from here. I can't think of anything else at this point.
35hz.co.uk exists and works, I've got that bit, but how on earth can www.35hz.co.uk not exist.
Ahh, no wait, I might have it. Just a moment. I've set up a CNAME record for www in 35hz.co.uk.
That according to google, should work.
EDIT: Do you ever get that feeling, when you've worked so long on something, and it finally works, you're not sure if you're imaginging it. I'm having one of those moments.
The /forum/ redirect didn't work, but, quite frankly. I'm not even remotely bothered about it.