I'm trying to configure a redirect on Nginx from a folder to a subdomain. I've tried already Nginx redirect: folder to external domain and Nginx rewrite rule (subdirectory to subdomain) and nginx: redirect subfolder to subdomain. Nothing works.
The problem, are simple. I have a Apache configured with this line:
RedirectPermanent /asd http://asd.domain.com/
Now, I'm trying to replicate this on a Nginx. Every configuration I've tried, have the same problem:
If I go to http://www.domain.com/asd/, they redirect me to http://asd.domain.com/asd/.
If I go to http://www.domain.com/asd/index, they redirect to http://asd.domain.com/index.
I need to delete the sub-folder in all cases, for me, the first one are incorrect. How can I configure nginx for in first case, go to http://asd.domain.com/?
The rules are applied after root parameter. The config are:
server {
listen --
server_name --
root --
<> INSERT RULE HERE
access_log --
error_log --
include - (A file with php configurations).
}
Some examples of tried rules:
rewrite ^/asd/(.*) http://asd.domain.com/$1 permanent;
rewrite ^/asd(.*) http://asd.domain.com/$1 permanent;
rewrite ^/asd(.*) http://asd.domain.com$1 permanent;
location ^~ /asd/ { rewrite ^/asd/(.*) http://asd.domain.com/$1 permanent; }
location ^~ /asd/ { rewrite ^/asd(.*) http://asd.domain.com/$1 permanent; }
location ^~ /asd/ { rewrite ^/asd(.*) http://asd.domain.com$1 permanent; }
Also, location variation with "location ~ ^/asd/(.)" or "location ~ ^/asd(.)"
Thanks,