Apache:Redirecting from subdomain to Wordpess page URL Path

0

I have a wordpress blog site that runs a sort of farm style instance. Each user has a url that is appended after the master subdomain(Example blog.CoolCompany.com/user)

I have to create a DNS record and vhost entry that links a new subdomain to a user's wordpress blog.

For example: marketing.CoolCompany.com must direct to blog.CoolCompany.com/user999

I have created a CNAME record that points marketing.CoolCompany.com to blog.CoolCompany.com. However I am stuck on creating a redirect of anything coming in from marketing.CoolCompany.com to the url path of /user999

Since this is a wordpress blog the pages are stored in the database so I can't just point to a local folder path. Is there a way to create a Vhost file or something similar that would direct the traffic from marketing.CoolCompany.com to blog.CoolCompany.com/user999?

HodgePodge

Posted 2017-02-15T18:24:48.143

Reputation: 1

Question was closed 2017-02-26T10:09:28.500

1

Please read the wordpress tag you included. You are asking an off-topic question. See On Topic. Questions about wordpress.com belong on [WebApps.SE]. Questions about installing and maintaining WordPress belong on [WordPress.SE]

– DavidPostill – 2017-02-24T15:15:22.823

Answers

0

For anyone who experiences something similar in the future a vhost file that looks like the following should work:

<VirtualHost *:80>

ServerName      marketing.coolcompany.com

RedirectMatch permanent ^/(.*$) http://blog.coolcompany.com/user999

ServerAlias marketing.coolcompany.com
</VirtualHost>

HodgePodge

Posted 2017-02-15T18:24:48.143

Reputation: 1