Hi all, I have a problem. My app server is nginx, on which my blog was hosted. when i visited my sitemap with this url: http://www.ikbear.com/sitemap.xml, it works.But when i visited my sitemap with this url: http://ikbear.com/sitemap.xml, it doesn't work. So i want to redirect http://ikbear.com/sitemap.xml to http://www.ikbear.com/sitemap.xml, would you tell me how can i do that in nginx? Thanks!
A:
Actually I'm going to venture a guess that you'll have the same trouble redirecting that url as actually serving it.
First, here's the syntax for a basic redirect:
server {
# ...
# redirect sitemap.xml to sitemap.xml.php
rewrite ^(/sitemap.xml)$ /sitemap.xml.php;
# ...
}
What might work for you is getting both www
and not-www
serving correctly. A common strategy is to serve all www
to non-www
, or vice versa. Here's an example of that:
server {
listen 80;
server_name www.mydomain.com;
# forward everything from www.domain.com to domain.com
rewrite ^(.*) http://domain.com$1 permanent;
}
server {
listen 80;
server_name domain.com *.domain.com;
location / {
root /var/www/domain/htdocs;
index index.html index.htm index.php;
# ... etc.
}
}
Garrett Bluma
2010-08-19 07:18:07
Thanks!I have resolved this problem thanks to this link:http://wordpress.org/support/topic/problem-with-sitemap-1
Ikbear
2010-08-19 08:20:02