I'm using nginx 1.0.8 and I'm trying to redirect all visitors from www.mysite.com/dir to google search page http://www.google.com/search?q=dir where dir is a variable, however if dir=="blog"( www.mysite.com/blog) I just want to load the blog content(Wordpress).
Here is my config :
location / {
root html;
index index.html index.htm index.php;
}
location /blog {
root html;
index index.php;
try_files $uri $uri/ /blog/index.php;
}
location ~ ^/(.*)$ {
root html;
rewrite ^/(.*) http://www.google.com/search?q=$1 permanent;
}
if I do this even www.mysite.com/blog will be redirected to google search page. If I delete the last location www.mysite.com/blog works great.
From what I've read here: http://wiki.nginx.org/HttpCoreModule#location it seems that the priority will be first on regular expressions and that first regular expression that matches the query will stop the search.
Thanks
location / {
rewrite ^/(.*)$ http://www.google.com/search?q=$1 permanent;
}
location /blog {
root html;
index index.php;
try_files $uri $uri/ /blog/index.php;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With