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
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
Where do I find the nginx configuration? And are there any settings in particular I should be I’m looking for ?
that depends on the server :/
Is there similar configuration available on Apache ?
I’m so dense with backend. So reverse proxy either Apache is what I’m looking for ?
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)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
i know what you what, and this is how you do it
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 ?
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:
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 deski 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