Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

richpeers's avatar

Nginx redirect folder after moving from shared server to forge - subfolder redirect to subdomain

so on the shared server i have laravel on domain.com/subfolder/public .

on forge with the domain A record , * and www pointing to a forge site, how would you redirect traffic from domain.com/subfolder/public to subfolder.domain.com with nginx config on forge? (main domain.com is gonna be static html)

ssh in and vim /etc/nginx/sites-available/domain.com but from there im lost with nginx

sounds unusual, but i have a mobile app in development pointing to the subfolder

0 likes
3 replies
Drfraker's avatar

Create a new site on the forge server called sub.domain.com and install your laravel app there. (you won't need to put it in domain.com/subfolder/public) In your dns settings point the address sub.domain.com to the IP address of your server.

richpeers's avatar

Thanks Drfraker, I understand how to do that, I trying to forward domain.com/project/public in one forge site to another forge site which is a subdomain like project.domain.com .

Reason being a mobile app is calling domain.com/project/public which needs to keep working until it's updated

richpeers's avatar

ok so after spending hours messing with /etc/nginx/sites-available/domain.com i found forge has a redirects option right in the UI! (also ability to edit above file directly in the interface!)

under the site / redirects menu, add a new redirect like:

from: ^/project/public/(.*)$

to: https://project.domain.com/$1

bobs your uncle

1 like

Please or to participate in this conversation.