Creating multiple landing pages with subdomains

I have to create landing pages on multiple subdomains e.g. shop.thedomain.com and academy.thedomain.com The pages are already built on thedomain.com Wordpress install. Is there a way to assign these subdomain URLs to these pages without creating brand new Wordpress installs in the subdomain directory and without using redirect; eg instead of redirecting the subdomain shop.thedomain.com to thedomain.com/shop the url bar should show the address as shop.thedomain.com and load the page content that exists at thedomain.com/shop Same with academy.thedomain.com . There has to be a way to do this without duplicating the Wordpress install files and database for one landing page labeled and accessible from the subdomain address
12 Replies
ἔρως
ἔρως3d ago
you can configure nginx to proxy the requests from the subdomain to those specific urls but the links and everything else would point to the other domain
clevermissfox
clevermissfoxOP3d ago
Where do I find the nginx configuration? And are there any settings in particular I should be I’m looking for ?
ἔρως
ἔρως3d ago
that depends on the server :/
clevermissfox
clevermissfoxOP3d ago
Is there similar configuration available on Apache ?
clevermissfox
clevermissfoxOP3d ago
I’m so dense with backend. So reverse proxy either Apache is what I’m looking for ?
ἔρως
ἔρως3d ago
the idea is to actually have apache do the request for you so, when someone requests abc.example.com, apache creates an http request to example.com/abc you can also implement this in php with file_get_contents you create an index.php file for the sub-domain and have it just send the contents (you will be better off using curl or fopen instead)
clevermissfox
clevermissfoxOP3d ago
I want the contents of example.com/abc to be shown for the request to abc.example.com , the point is I don’t want to have to make a whole separate Wordpress install and duplicate database under the sub domain files when everything already exists on the main domain files. And redirect would change the address in the url bar. Forgive me if I’m misunderstanding
ἔρως
ἔρως3d ago
i know what you what, and this is how you do it
clevermissfox
clevermissfoxOP2d ago
Okay thank you I was confused what you meant by the index.php for the subdomain but I guess it could be an empty file ? It just needs to exist ?
Jochem
Jochem2d ago
you'd basically create a sort of proxy on your own in PHP, but it's a terrible solution compared to just using Apache mod_proxy that index.php would live in the subdomain and using mod_rewrite receive all the requests for that subdomain, then act as a router to fetch and display data from the other site by it doing an HTTP request it's one of those "yeah, it would technically work" solutions I'm using mod_proxy on my home server to pass some traffic on a subdomain through to a raspberry pi. This is in the apache config file for the subdomain I'm using:
ProxyPass "/" "http://192.168.178.76/"
ProxyPassReverse "/" "http://192.168.178.76/"
ProxyPass "/" "http://192.168.178.76/"
ProxyPassReverse "/" "http://192.168.178.76/"
at the end of the day, this is much more a sysadmin issue than a programmer issue though. Not to say it's not something to ask here, just that if you've got a sysadmin where you work, dump this on their desk
ἔρως
ἔρως2d ago
i couldnt have said it any better the index.php solution is the last last last last last resort so last that papa roach wouldnt sing about it you only use this because you have to
Want results from more Discord servers?
Add your server