Reputation: 1
I have dynamic laravel application, after registration user get it's own subdomain example.myapp.com
and that's fine, now the agency develops marketing website which we would like to place on main domain: myapp.com
.
What I tried:
I tried to play around with A record but that doesn't worked.
The possibility would be of course to load everything with curl
but then that's not SEO friendly because the page would need to be hosted on a subdomain as well.
Upvotes: 0
Views: 71
Reputation: 1
I would solve this issue by using a reverse proxy (NGINX for example).
Note that this is only a pseudo example!
# Server block for subdomains
server {
listen 80;
server_name *.example.com;
location / {
proxy_pass http://subdomain_backend_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# Server block for URLs without subdomain
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://no_subdomain_backend_server;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
In the above configuration:
Make sure to replace example.com with your actual domain name, subdomain_backend_server with the URL of the backend server for subdomains, and no_subdomain_backend_server with the URL of the backend server for URLs without a subdomain. Adjust the configuration as needed for SSL/TLS or any other specific requirements.
Hope this helps you on the way!
All the best.
Upvotes: -1