Last active
August 29, 2015 14:10
-
-
Save jennimckinnon/504f60b4452da6fa963f to your computer and use it in GitHub Desktop.
Addings dynamic 301 redirects to the .htaccess file for WordPress from sub-directories to sub-domains
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You need the following line before the redirects for this to work | |
RewriteEngine On | |
# 301 Redirect to subdomain no query strings attached to the end of the redirected URL | |
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] | |
RewriteCond %{QUERY_STRING} ^page_id=10$ [NC] | |
RewriteRule ^site1/$ http://site1.yourdomain.com/newpage? [R=301,NE,NC,L] | |
# 301 Redirect to subdomain with query strings attached to the end of the redirected URL | |
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC] | |
RewriteCond %{QUERY_STRING} ^page_id=10(&.*)?$ [NC] | |
RewriteRule ^site1/$ http://site1.yourdomain.com/newpage?%1 [R=301,NE,NC,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment