0

I have multiples subdomains that I want to redirect in nginx or php like that

Example: test.test2.domain.com to domain.com/test/test2

It's possible to do a 301 Redirect in nginx so in php I can get the parts test and test2 as params ?

Thanks

rzx10r
  • 134
  • 1
  • 1
  • 9
  • Try https://stackoverflow.com/a/14502147/4875631 and add another variable in there. If it doesn't work, post back with what you've tried. – Blue Oct 22 '18 at 13:37

2 Answers2

0

Try this

server {
  server_name test.test2.domain.com;
  location / {
    return 301 domain.com/test/test2;
  }
}

https://www.digitalocean.com/community/questions/how-do-i-permanently-redirect-subdomain-to-specific-url

Jozef Cipa
  • 2,133
  • 3
  • 15
  • 29
0

Put this in your nginx configuration file

server {
    listen *:80;
    server_name test.test2.domain.com;
    return 301 $scheme://domain.com/test/test2/$request_uri;
}
gounane
  • 381
  • 2
  • 6