0

I successfully able to setup nginx and apache combination to serve wordpress blog with the help of this site. I exactly followed all the codes supplied in that site and following is the directory strcture of my blog and sub-blog.

main.com(wordpress)
---/mainBlog(wordpress)

I have no problems at all while surfing (main.com) but sometimes, if I call

http://main.com/mainBlog

the browser is redirected to

http://main.com:8080/mainBlog

and got "Cannot connect to server" error from browser. "8080" is used as proxy port where nginx transfer all dynamic content traffics to Apache. But if I type this http://main.com/mainBlog again in the same address bar, problem disappear again. It would be annoy to users who doesn't know to reload the page without "8080" port.

Edit: I just found out that, if I leave slash at the end of the url, I got that problem but if I put slash, no problem at all. Where can I define for that problem?

2 Answers 2

1

This is actually Apache (or PHP) sending the redirect, so you need to fix it there, you cannot change this in Nginx unless you want to actively make nginx redirect no trailing slash to trailing slash.

rewrite ^(.*[^/])$ $1/ permanent; will do it.

2
  • Thanks a lot Martin. Would u mind if I ask where to put that line? I'm not very good with server things and still learning.
    – Devyn
    Jul 8, 2011 at 18:43
  • Hi! I suggest you read this: wiki.nginx.org/Quickstart If you still have questions afterwards then go ahead and ask. Jul 8, 2011 at 22:54
1

I had a similar problem with varnish and nginx (varnish on port 80 proxying to nginx listening on 8080) and needed to add "port_in_redirect off;" ... server_name_in_redirect needed to stay on so nginx knew which host it was handling.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .