3

Let's say I have name.example.com and example.com set up using different CMS's

I would like name.example.com/supercool-landing-page to resolve as (www.)example.com

In other words, when you visit (www.)example.com, what you are really seeing is name.domain.com/supercool-landing-page. However, it is important that the url stays as (www.)example.com, for SEO reasons (for on-page content and user experience).

My reason for wanting to do this is because the CMS that's powering example.com is not good for creating landing pages with, whereas name.example.com is running Wordpress, which is perfect for creating landing pages with.

5

This type of indirection is called a reverse proxy setup.

To reverse proxy in Apache2, use the ProxyPass directive in your config for www.example.com:

ProxyPass "/"  "http://name.example.com/supercool-landing-page"

To reverse proxy in nginx, use the proxy_pass directive in your config for www.example.com:

location / {
    proxy_pass http://name.example.com/supercool-landing-page;
}

Those aren't complete configurations, you also need to proxy_pass all the resources (images, js, css) that are used by the WordPress page. But it should help get you started.

The final piece of the puzzle is to make sure your apex domain (example.com) is redirecting to www.example.com. This is good practice for any website.

8
  • Thanks, I'll give that a shot! In the meantime, quick question: is the opposite of the apex domain (example.com) redirecting to www.example.com, alright or should it always end up as www.example.com? (in my case www.example.com redirects to example.com) Thanks a lot.
    – Gottano
    Oct 7 at 18:21
  • 3
    @Gottano The short answer is that it's fine to host on either apex or www. The long answer is that there are some very subtle, usually but not always negligible disadvantages to hosting on the apex domain, so I am of the opinion that given a choice, everyone should be using www. Whichever one you choose, redirect the other one to it. Oct 7 at 19:04
  • OK so I am with Cloudways and they told me they don't allow "customization of their stack", so they do not make "httpd.conf" available. What other files should I look to modify instead? Sorry for asking but they aren't being proactive and feel I need to ask them directly if "this" and "that" is possible.
    – Gottano
    Oct 11 at 15:59
  • 1
    @Gottano I found a bit more context on this post, but I'm nearing the edge of my experience. A comment at that link suggests using RewriteRule with the P flag. Support should have at least told you what directive to use or given an example! Oct 11 at 17:17
  • 1
    I know, right? Well, many thanks for your help so far!
    – Gottano
    Oct 11 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.