How do i create virtual subdomain using htaccess?

Redirect multiple wordpress subdomains to main domain using htaccess BUT exclude one?

  • I have recently moved a large site with multiple subs and am consolidating all content into one domain. So I HAD. siteA.domain.tld siteB.domain.tld siteC.domain.tld which I need to redirect to http://domain.com I have also added the NEW subdomain newsite.domain.tld How do I write the htaccess file to redirect all but the new subdomain to the main site?

  • Answer:

    Something like this should work: RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} ^*\.domain\.tld RewriteCont %{HTTP_HOST} !^newsite.domain.tld RewriteRule ^(.*)$ http://domain.com/%241 [R=301,L]

Chris Wiegman at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.