As the question says really, How can I make Wordpress redirect all requests to subdomain.domain1.com to www.domain2.com.
I have a wordpress site on windows azure - I've added the below to the htaccess file but nothing seems to be happening:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(.*)subdomain.domain1.com/$ [NC]
RewriteRule ^(.*)$ http://www.domain2.com/$1 [R=301,L]
Change your rule to:
RewriteCond %{HTTP_HOST} ^subdomain\.domain1\.com$ [NC]
RewriteRule ^ http://www.domain2.com%{REQUEST_URI} [R=301,L]
WP permalink settings
The following is the comments summarised into the answer:
For wordpress sites hosted on on azure (and therefore in IIS) you dont use the htaccess file for rewrites, you actually need to add a web.config as described here http://www.davebost.com/2013/07/11/moving-a-wordpress-blog-to-windows-azure-part-5-moving-from-a-subfolder-to-the-root
The following rewrite rule would achieve the required result:
...
<rule name="Redirects to www.domain2.com" patternSyntax="ECMAScript" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTP_HOST}" pattern="^subdomain.domain1.net$" />
</conditions>
<action type="Redirect" url="http://www.domain2.com/{R:0}" />
</rule>
...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.