Domain Alias Redirecting

Webmaster WordPress Leave a Comment

Redirect domain alias (subdomains) with WordPress using the .htaccess file. This also fixes problems wordpress has using subdomains as main URL.

You may be using www. or uk. or any other subdomain as your main wordpress URL, this .htaccess  hack converts all domain aliases not used as blog url to reside frontend of your main url.

Example: uk.elance.me/wordpress would redirect use SEO friendly techniques to www.elance.me/wordpress/?source=uk.elance.me.

Domain alias are usually a  (301 cloak) and shows the visited subdomain including url string and hiding the main URL in the browser address bar. The WordPress admin bar will also be hidden/unavailable even when logged in to the site when using visiting a domain alias URL.

.htaccess (with subdomain)

RewriteCond %{HTTP_HOST} !^(www\.)?elance\.me$ [NC]
RewriteRule ^(.*) http://www.elance.me/$1?source=%{HTTP_HOST} [R=301,L]
RewriteCond %{HTTP_HOST} ^elance\.me$ [NC]
RewriteRule ^(.*)$ http://www.elance.me/$1 [L,R=301]

.htaccess (without subdomain)

RewriteCond %{HTTP_HOST} !elance\.me$ [NC]
RewriteRule ^(.*) http://elance.me/$1?source=%{HTTP_HOST} [R=301,L]

.htaccess (Example)

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{HTTP_HOST} !^(www\.)?elance\.me$ [NC]
RewriteRule ^(.*) http://www.elance.me/$1?source=%{HTTP_HOST} [R=301,L]
RewriteCond %{HTTP_HOST} ^elance\.me$ [NC]
RewriteRule ^(.*)$ http://www.elance.me/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Edit your current .htaccess with the correct section from above replacing Site URL with your own.

Redirection (downloaded from the WordPress plugin directory

The URL redirection plugin can be used to manage and track to your domain alias redirects.

Example:  Use this WordPress plugin to redirect www.elance.me/?source=uk.elance.me to the main URL www.elance.me or www.elance.me/uk ect.

Jonradio Multiple Themes (see google for source)

You can also set a specific themes for different keyword, URL’s and value queries using jonradio Multiple Themes. Use the query string after the ?source=uk.elance.me to map themes such as mobile themes or test themes.

Leave a Reply

Your email address will not be published. Required fields are marked *