1

Normally if you have one WordPress website it is easy to create rewrite rules in the .htaccess file for your domain. For example, if your domain is DomainA.com and you have the following rewrite rule:

RewriteRule ^i-like-([a-zA-Z0-9-]+)/$ wp-content/themes/customtheme/custom-pages/ilike.php?like=$1 [L]

You will get DomainA.com/i-like-...

But what if I have a multisite with the following domains:

  • DomainA.com (primary domain)
  • DomainB.com (Mapped domain)
  • DomainC.com (Mapped domain)

And I want to create a rewrite rule for DomainB.com for a specific file like above?

Is there a way to achieve this?

2

If you wanted to target a specific domain then you need a condition (RewriteCond directive), preceding the RewriteRule that checks for the specific domain (Host: header). For example:

RewriteCond %{HTTP_HOST} ^domainb\.com [NC]
RewriteRule ^i-like-([a-zA-Z0-9-]+)/$ wp-content/themes/customtheme/custom-pages/ilike.php?like=$1 [L]

The HTTP_HOST server variable contains just the Host: header sent in the request.

Reference:
http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond

1
  • 1
    Awesome, thanks MrWhite! Searching for this for quiet a while..
    – Erik
    Dec 20 '17 at 10: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.