'Redirect subfolder to root with nginx
I’ve moved my wordpress site from example.com/mobile to example.com.
For this work, I want:
- example.com/mobile not redirect. I want it not redirect because I have a category with mobile slug on example.com.
- example.com/mobile/anycharacter redirect to example.com/anycharacter
This is my nginx rule:
location ~ ^/mobile/ {
rewrite ^/mobile/(.*?)$ https://example.com/$1 permanent;
}
This worked with:
- example.com/mobile redirect example.com
- example.com/mobile/anycharacter redirect to example.com/anycharacter
Anyone have suggest to help me solve this problem (not redirect example.com/mobile to example.com)?
Thank you very much!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|