Forum Moderators: phranque
I am trying to make it so that blueshoes.com redirects to blueshoecompany.com but am not sure how to go about doing this.
redirect 301 / [blueshoecompany.com...]
The above line does not work because it is causing blueshoecompany.com to redirect to itself and the site stops loading. Will I need to suggest that we assign an IP to each domain name or is there another way to do this? They've been working this way for quite a while and will need some very good reasons to assign IPs to each just so that they can be redirected.
Can I accomplish a redirect like this through a mod_rewrite? If so, does anyone have any ideas that I can pass on the programmer.
Your poor ole redirect is just doing what you told it to do... ;)
From the Apache docs [httpd.apache.org]:
Syntax: Redirect [status] URL-path URLYou are redirecting from the root folder (URL-path) of your site to the URL that resides at the root of your site.
I think RedirectMatch [httpd.apache.org] is probably what you are looking for.
Syntax: RedirectMatch [status] regex URLI'm no regex expert but something like this should get you going in the right direction:
You could add RedirectMatch directives for additional domains. If you have many domains, a mod_rewrite solution could also be used that could "distill" a lengthy series of RedirectMatch directives into any few lines.
Welcome to WebmasterWorld [webmasterworld.com]!
In order to discriminate between the two domains, you'll need to test the {HTTP_HOST} variable, that is, the domain requested by the browser that ended up on your server. If it is not the "primary" domain name, then redirect it to the primary.
To do this, you'll need to use mod_rewrite, which may or may not be available to you.
Several examples of the code to accomplish what you need have been posted in this forum. Message number 3 in this thread [webmasterworld.com] shows the code; simply substitute the domain name you want to redirect into the first line, and the one you want to keep into the second line.
Note that this code is "forgiving" of www- and non-www variants, as well as upper/lowercase variants. This may not be what you want, but you can change it easily.
Jim