Creating redirects list from a domain alias to a primary domain

Creating redirects list from a domain alias to a primary domain - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Creating redirects list from a domain alias to a primary domain error on your web browser. Problem :


I am trying to set up a list of redirects in my .htaccess to create a manually defined 'short url' list, whereby the short url domain ("short.com") is set up as an alias for the destination domain ("longdomain.com").



The problem I'm running into is that –as expected– this basic redirect from the root works fine:



Redirect /howto http://longdomain.com/tutorials/how-to-do-something  
Redirect /where http://longdomain.com/directions/where-is-my-car


...but is not suitable for redirecting to another domain. However, including the domain name like this:



Redirect short.com/howto http://longdomain.com/tutorials/how-to-do-something  
Redirect short.com/where http://longdomain.com/directions/where-is-my-car


...is not working for the domain alias. It doesn't redirect, it just loads the content (/howto and /where) from the primary domain. Content that doesn't exist there I might add, so it ends up showing nothing.



Is there any way to create a similar redirects list from a domain alias to a primary domain? Or do I need to do a Rewrite for this? And what would that look like?



EDIT - A HOPEFULLY BETTER DESCRIPTION OF THE ISSUE

I have a short and a long domain, both with the same DNS, the short domain set up as an alias for the primary.

I need to create short urls to content on the primary domain. I will do this manually as I need readable URL's, not randomly generated strings. So: short.com/snowwhite would go to long.com/stories/fairytales/snowwhiteandthesevendwarfs.


Solution :

The Redirect directive doesn't pay any attention to the current host name. Your intention of



Redirect short.com/howto http://longdomain.com/tutorials/how-to-do-something  


appears to be to only redirect when the domain name is "short.com". mod_alias's redirect doesn't suport this syntax. The short.com/howto argument must only be a URI path (starting with a slash).



You could solve this problem using the <if> directive



<If "%HTTP_HOST == 'short.com'">
Redirect permanent /howto http://longdomain.com/tutorials/how-to-do-something
</If>


Alternately, you could use mod_rewrite:



RewriteEngine  on
RewriteCond %HTTP_HOST short.com [NC]
RewriteRule ^/howto$ http://longdomain.com/tutorials/how-to-do-something [L,R=301]


I have made the redirects permanent (301) redirects in my above examples which is more SEO friendly than the default 302 temporary redirects you had been using.



Why not set up a CNAME record from short.com pointing to longdomain.com and then, based on your examples, the incoming requests would work without any short.com .htaccess rules.


We hope that this article has helped you resolve the htaccess, redirects, custom-short-url error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=