Last active
August 29, 2015 14:14
-
-
Save codfish/869e741b45ac95f1d1ea to your computer and use it in GitHub Desktop.
Scenario: You use a subdomain for your WP Admin separate from your blogs main domain, i.e. admin.superblog.com. You want to make sure only requests to the WP admin use this subdomain. This apache rewrite logic redirects all non-admin traffic away from admin domain to the homepage, keeping in mind that preview urls should also be included as an a…
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
RewriteEngine On | |
RewriteBase / | |
# http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html | |
# "If you wish to match against the full URL-path in a per-directory (htaccess) RewriteRule, | |
# use the %{REQUEST_URI} variable in a RewriteCond." | |
RewriteCond %{HTTP_HOST} ^admin.superblog.com$ | |
RewriteCond %{REQUEST_URI} !^(/wp-admin|/wp-login|/wp-content|/wp-includes) | |
RewriteCond %{QUERY_STRING} !^(.*?)preview=true(.*?)$ | |
RewriteRule (.*) http://superblog.com? [R=301,L] # the trailing ? after the domain makes sure to remove any query string params from the original request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment