Forum Moderators: phranque

Message Too Old, No Replies

301 redirect with no root directory

Apache 301 redirect with both domains pointing to the same IP address.

         

abezgauz

8:41 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



I have a customer that redisigned their site and changed their URL. Of course, what needs to be done is add a 301 redirect to the old URL since the content on both are identical. I have asked them to put in the redirect and have been told that there is no root directory for the old site. "Both domains point to the same IP addresses, our ISP's DNS servers are configured this way."

I have read through many of the 301 redirect posts but can't seem to find anything that is similar to my situation. Please help! Thanks.

Note: They use Apache.

DaveAtIFG

3:11 pm on Sep 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It sounds as if these are "virtual domains" meaning they are both hosted at the same IP. Re: The Resource Identified by a Request [w3.org].

Each site has a "site root," a directory in which the default HTML file resides (usually index.html). An .htaccess file containing your redirect should be placed in the site root directory of the domain you want to redirect.

Also, if you have access to the httpd.conf file, it defines the configuration for both domains. Instead of using .htaccess, your redirect could be added to the section defining the domain you want to redirect.

jdMorgan

4:11 pm on Sep 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This appears to be the same kind of problem faced by Webmasters who want to redirect from their www.example.com domain to their example.com domain. Since both are hosted in the same filesystem space, it requires the use of mod_rewrite to check the requested HTTP_HOST and act accordingly. In your top-level .htaccess file, something like

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com
RewriteRule (.*) http://new_domain.com/$1 [R=301,L]

would probably do what you need to do.

See the references cited in our Apache forum charter [webmasterworld.com] for more information about mod_rewrite.

Jim