I'm building an Angular website which will also have a small WordPress installation for the marketing/sales team (to build landing pages). our marketing team is adamant that subdomains are bad for SEO, and for GA, and would like the WordPress installation to be in a subdirectory. ex:

example.com/ <-- Angular example.com/marketing/ <-- WordPress

Angular is installed on an S3 bucket, WordPress is installed on an EC2 (behind a load balancer), and the whole thing is hidden behind a Cloudfront distribution! almost everything is working for me at this point: example.com/marketing/ DOES correctly load up the WordPress site, and example.com/ DOES load Angular (and example.com/some-random-path correctly invokes the /index.html Angular front-controller). the problem I'm having is that example.com/marketing/some-random-path ALSO invokes the /index.html Angular front-controller, since example.com/marketing/some-random-path 404s. but for WordPress to work, 404s within /marketing/ need to instead hit the /marketing/index.php WordPress front-controller.

I looked into Amazon's lambda functions, but I wasn't sure how to get that working properly in combination with the WordPress .htaccess. maybe the solution to all my problems lie there?

or maybe there's another way to configure this "fake" /marketing/ subdirectory. is it a requirement and/or best-practice that it be wrapped up behind Cloudfront? none of our other WordPress sites are.

maybe there's some super-sneaky DNS thing I can do that I'm not aware of?

I'm open to alternative configurations; the one I've described is simply the one I've managed to figure out thus far.

one more note, if it's relevant: our domain names are registered with a third-party registrar (dnsmadeeasy), and not Amazon; dnsmadeeasy has (slightly?) faster DNS resolution, which other people working here are not keen to give up. I'm not sure it's relevant for this problem, but it has made configuration slightly more troublesome for me, so on the off chance that could be relevant, I thought I'd mention it.

  • 1
    "Subdomains are bad for SEO" is a ridiculous myth and it really needs to die. Tell your marketing team to Google it. – Michael Hampton Mar 26 '19 at 22:25
  • it sounded silly to me. I'll google myself, and see if I can't find them any resources. one of the complaints that did make sense to me (but isn't about SEO) is that in GA, if you have a URL called, I dunno /stuff on one subdomain, and /stuff on the other, that they appear the same in GA? but I'll do some googling; I was skeptical that subdomains should impact SEO, but marketing was very adamant, so I was like "alright; dude's done his research; who am I to argue?" :P – Ben Mar 27 '19 at 12:23
  • Dude hasn't done his research, so ... As for GA, you have to set up the subdomains as separate subdomains in GA. Maybe that's what he is having a problem with. – Michael Hampton Mar 27 '19 at 14:15

I mapped subdomains for each individual application (one subdomain for s3, and one for wordpress) and then introduced a proxy server on the root domain to route to logical sub directories which were proxy upstreamed to the subdomains I had previously mapped. This could also theoretically work with IPs but it's easier for me to use subdomains when working with S3 as a website and with EC2/ElasticBeanstalk. NOTE: I used this configuration with over 20 S3 sites mapped as directories under a custom java proxy server. Depending on your requirements you have to decide whether or not you want to use one server to run your wordpress or if you will engage in any kind of scaling with it (for instance running multiple instances behind a load balancer). If you opt for a load balancing configuration on wordpress in the future, then you should implement a separate instance to run as your proxy server to route the paths to each upstream application source. If you are looking for simplicity without regard for scale you could implement multiple virtual hosts on the wordpress server instance and then configure proxy paths for s3 and your wordpress installation against a virtual directory structure.

  • I like the proxy server idea! we are already using load-balancers, and WP and Angular definitely won't live on the same sever, since Angular hosts nicely without a web server (S3!) do you happen to know any good resources that would help create the setup you're describing? (I'll definitely be doing some googling along these lines, myself!) – Ben Mar 27 '19 at 12:21
  • I used a spring boot implementation that was very lightweight to run as a basic case for basic routing without a lot of bells and whistles. The principal technology was their "netflix eureka discovery" technology which allowed very easy mapping of services using a yml spring configuration file (and a could of annotations on a main class) – The Prophet Jun 6 '19 at 19:07

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.