Matt L. Smith | Uncategorized Archives - Matt L. Smith
1
archive,category,category-uncategorized,category-1,ajax_fade,page_not_loaded,,wpb-js-composer js-comp-ver-4.1.2,vc_responsive

Uncategorized

htaccess-image

How to Redirect all URLs to Another Domain

  |   Uncategorized   |   No comment

office-space-printer-beat-down-gifFirst let me say this should have been a whole lot easier then it actually was. Trying to find a solution left me feeling very angry. But alas after failing for several hours I found the right solution. Recently I wanted to redirect all the pages from one domain to another. Specifically I wanted to redirect all the URLs from a sub-domain to the main domain. My goal was to redirect all wildcard URLs (anything on the sub-domain) to my new domain. When I tested a few different htaccess code snippets I found they didn’t accomplish exactly what I wanted. In most cases it would redirect the sub-domain correctly but it wouldn’t redirect the wildcard URLs correctly. However, after much searching I was able to find this code that works perfectly. So if you are like me and need to redirect all your wildcard URLs and your domain use this snippet of code on your servers htaccess file.

 

That can be found by simply going to the root folder of the domain you want to redirect and .htaccess will be there. Just use a notepad editor or anything else and add this snippet.

 

RewriteEngine on
RewriteCond %{http_host} ^http://mysubdomain.domain.com [NC,OR]
RewriteCond %{http_host} ^mysubdomain.domain.com[NC]
RewriteRule ^(.*)$ http://www.newdomainyouwanttoredirectto.com[R=301,NC,L]

 

Save and your done. That’s it! Now all the random URLs on your old domain will redirect to your new root domain. If you want to redirect 1×1 content I would suggest redirecting your root folder and then using Joosts redirect manager in SEO tools pro.

Read More