Created
November 25, 2014 00:40
-
-
Save jennimckinnon/1a1027ecb1fcac81ee25 to your computer and use it in GitHub Desktop.
Addings dynamic 301 redirects to the .htaccess file for WordPress from sub-domains to sub-directories.
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 subdirectory no query strings attached to the end of the redirected URL | |
RewriteCond %{HTTP_HOST} ^site2\.yourdomain\.com$ [NC] | |
RewriteCond %{QUERY_STRING} ^page_id=20$ [NC] | |
RewriteRule ^$ http://www.yourdomain.com/site2/newpage? [R=301,NE,NC,L] | |
# 301 Redirect to subdirectory with query strings attached to the end of the redirected URL | |
RewriteCond %{HTTP_HOST} ^site2\.yourdomain\.com$ [NC] | |
RewriteCond %{QUERY_STRING} ^page_id=20(&.*)?$ [NC] | |
RewriteRule ^$ http://www.yourdomain.com/site2/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