1

One of my clients has a Wordpress site that is a multisite installation. They are running a new campaign that I have set up as a page under the main site at example.com/summer/. However, they sent marketing materials to print that list the URL as summer.example.com. Is there any way to redirect that subdomain to the proper page without having to set up a whole new multisite?

I tried sending the A record of the subdomain to the IP address of the site. Then used .htaccess and added the following lines:

RewriteCond %{HTTP_HOST} ^summer\.example\.com
RewriteRule ^(.*)$ https://example.com/summer/$1 [R=301]

That redirects the subdomain to example.com/wp-signup.php?new=summer

Any ideas?

Update: I've added the wp-config definition of ('NOBLOGREDIRECT', '%siteurl%') which gets summer.example.com redirecting to example.com. This is not the fix I need, but just reporting back on potential fixes I'm seeing around.

1
  • 1
    I'd probably set up a new VirtualHost in Apache for summer.domain.com and put the rewrite rule there. At the moment it looks like the rewrite isn't happening and WordPress is trying to treat this as a new multisite.
    – Rup
    May 20 at 11:58
1
RewriteRule ^(.*)$ https://example.com/summer/$1 [R=301]

You need to include the L flag on the RewriteRule directive, ie. [R=301,L] and ensure this rule is near the top of the .htaccess file, before the existing WordPress directives.

Without the L flag, processing continues and the request is further rewritten (by the WordPress front-controller) before the eventual (incorrect) redirect.

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.