Nginx redirect: folder to external domain
I’m trying to redirect domain1.com/blog/$ to domain2.com/$.
How do I edit this to strip the /blog from the redirect?
location /blog {
rewrite ^/(.*) http://domain2.com/$1 break;
}
It now redirects domain1.com/blog/blabla to domain2.com/blog/blabla (so blog is still there)..
Thanks in advance!!
You want the regex part of your rewrite to match against ^/blog/ and capture everything following it:
rewrite ^/blog/(.*) http://domain2.com/$1 break;
Using such an approach, you may also be able to get rid of the location block.
Check more discussion of this question.
Related posts:
Leave a comment
Recent Posts
Tags
active-directory
amazon-ec2
apache
apache2
backup
bash
centos
cisco
command-line
debian
dns
email
exchange
firewall
iis
iis7
iptables
linux
macosx
monitoring
mysql
networking
nginx
performance
permissions
php
postfix
raid
security
sql-server
sql-server-2005
sql-server-2008
ssh
ssl
ubuntu
unix
virtualization
vpn
webserver
windows
windows-7
windows-server-2003
windows-server-2008
windows-server-2008-r2
windows-xp





