Hello All,

We have been handed the hosting for a site that was previously hosted by another company. As this is our first Drupal site, we required to build a new server to host the site upon. I setup an Ubuntu 8.04.3 LTS installation, with Apache2 (v2.2.8), MySql (v14.12 Distrib 5.0.51a), PHP (v5.2.4-2), on an internal IP: 192.168.6.80

I enabled the rewrite module for apache, and installed php5-gd, and php-pear. I think that's all I had to do as far as meeting requirements - if there were any more, they were met without any issue.

Uploaded the site to /var/www, and wrote some Apache configuration that appears to be specific to Drupal. This all appeared to work just fine (after some rewrite frustration, which I solved by reading forums). I was able to use phpmyadmin to query the SQL, change passwords etc. I was able to login just fine on the new IP for Drupal installation: 192.168.6.80/user/login. Everything worked just fine. And the site was browsable on 192.168.6.80 - everything works.

We decided this morning to add a DNS entry into the network so we can show the site off to the client. Someone else here NAT'd a public IP to our site, lets call that 203.167.X.X. And then an A record was pointed to that address: subdomain.manux.co.nz -> 203.167.X.X

Now browsing to the external IP, I can see the browser hit the Linux server, but only for a second before Apache throws a damn 302 redirect and then whatever browser you're using gets chucked over to sodastream.com, which is hosted by other people in other parts of the world.

I have absolutely TRAWLED my Apache config, Drupal config, and MySQL database for anything that is causing this to happen, but simply cannot find any directive causing this. I have been hacking away at my Apache config all morning trying every redirect method and rewrite method possible to relieve this problem, but the site either breaks (can't find "/") or continues to redirect to the .com site. I am in New Zealand, I want to run the .co.nz site. I am NOT using a DNS that is causing this issue, we registered subdomain.manux.co.nz for this. Notably the same thing happens when hitting http://subdomain.manux.co.nz - one gets redirected.

Now I'm starting to get annoyed. Why? Because I hosed /var/www and loaded another client's site into there, changing as little as possible Apache configuration - in fact I only had to change the line which restricts you to using index.php, disallowing index.html etc etc, and the site works fine (It's not a Drupal site, not that that matters).

So, I'd really like to know why Drupal is forcing a 302 on Apache when the Real World IP is hit, and NOT when the LAN IP is hit?

I'd really like to know _where_ in the Drupal configuration it is being told to redirect to the USA site. I have done full text searching over the whole site directory and have not found any config pertaining to this. I have also searched through the MySQL database looking for the same thing, and have even manually browsed most of it. I have checked through the Drupal Admin settings after Admin login on the webpage from the local IP 192.168.6.80, and still nothing!

Please help, this is driving me crazy, and there is no rhyme or reason for this happening!

Unless, is it possible for a directory in the Drupal web folder is not set to correct permissions, and Drupal is thinking it is down for maintenance and is redirecting because of that (I know this is possible in the Admin configuration, but it is NOT set).

please please please help.

Comments

mhutchinson’s picture

Anticipating someone telling me that I've gone through the wrong procedure for migrating the site, I have started a new Virtual Machine and will setup Drupal from scratch there. After doing this I will overlay the Client's Drupal site over the top of the existing one. This will soon tell me if the install.php has anything to do with it. Still would like some answers from the above though, if anyone has any.

mhutchinson’s picture

OK well thanks, I guess I'm going it alone.

dman’s picture

Darn, I was just about to write up a couple of troubleshooting steps that would help you - concerning wht NAT may be tricky when working with Drupal subdomain detection, a few methods for tracing what was really going on with the redirect at the http level, and where that external address may possibly be coming from.

... but I see from your response that you don't want that help after all.
Have fun.

mhutchinson’s picture

I really would like that help, especially to do with tracing what is going on at HTTP level - it seems my network administrator doesn't know how to do this.
Sorry if I offended you.

Chad_Dupuis’s picture

It's a little hard to say for certain but the only place that "drupal" can redirect something is from rules in it's own .htaccess file. If you grab a clean one from a fresh install you should be alright. I suppose the previous user could have installed a module of some type that performed redirects but that is unlikely.

If the .htaccess file looks fine, chances are extremely high that this has absolutely nothing to do with drupal.

I don't know if they will be helpful but I have some setup notes for apache/drupal on my site.

mhutchinson’s picture

I have moved all of the .htaccess rules, after reading about some security issues, to the apache configuration for the site. Here's what I have in the original .htaccess file that came with the site:
(I still dont see how a 302 redirect is happening)...

#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.

Order allow,deny

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php

# Force simple error message for requests for non-existent favicon.ico.

# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# PHP 4, Apache 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# PHP 5, Apache 1 and 2.

php_value magic_quotes_gpc 0
php_value register_globals 0
php_value session.auto_start 0
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0

# Requires mod_expires to be enabled.

# Enable expirations.
ExpiresActive On

# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600

# Do not cache dynamically generated pages.
ExpiresByType text/html A1

# Various rewrite rules.

RewriteEngine on

# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

# $Id: .htaccess,v 1.90.2.3 2008/12/10 20:04:08 goba Exp $

mhutchinson’s picture

Chad,

Thanks for the notes, I have had a good read, and will use the new VM shell following your steps, and see if that makes the site work properly.

Thanks and Cheers,
Mike