I would like to develop a drupal site, and have it available at test.sitename.com. The current (static html) site should remain available at www.sitename.com

I have installed drupal and created a subdirectory for the test site at:
drupal/sites/test.sitename.com/

I have set the correct $db_url in /test.sitename.com/settings.php and in drupal/sites/default/settings.php

When I browse to test.sitename.com I get "server not found" (not surprising)
When I browse to www.sitename.com I get the index of the static page (which is what I want).
When I brose to www.sitename.com/drupal I get the drupal site.

So how do I tell my webhost to send incoming requests for test.sitename.com to /drupal/index.php ? (I assume drupal will handle the rest from there.) Do I need to mess around with the .htaccess file in the root web directory (the one that the drupal directory lives in) to do some URL redirects?

The install instructions don't help much with this.

Thanks for your help!

Comments

vm’s picture

you could just do a meta redirect to the drupal folder. adding an index.html to your subdomain. like below.

<html>
<head>
<title>Redirecting...</title>
<meta http-equiv="refresh" content="0;url=http://www.yoursite.com/drupal">
</head>
<body>
</body>
</html>

however, you could also set up an actuall subdmain on your host, and install drupal into the actual subdomain folder. then a redirect wouldnt be needed at all. you drupal site will be available at test.yoursite.com.

kleingeist’s picture

The redirecting wont work, while there is no sub-domain configured by his hoster. And the error message "Server not found" looks much like that (you could test if test.sitename.com solves to any adress using http://www.dnsstuff.com or something like that)

So this isn't a thing anyone here could really help. You have to contact your Webhost and tell him you would like to got a subdomain, which uses the drupal folder as root.

hope this helps a little.

isaac77’s picture

Thanks for your response. You are quite correct; I was a little confused about how subdomains work. Now I realize that I cannot use subdomains with the type of shared server account that I have. I am going to try and set up a test sub-DIRECTORY instead of a subdomain.

rivena’s picture

(easiest) You should be able to install Drupal in the sub folder just as well as you can in the root folder.

If you are going to do a URL redirect, then it would have to be the other way around, from the drupal subfolder to the test subdomain (where the content is). The test subdomain would show up in the URL.

(a little harder) If you want drupal to stay where it is, but appear to be in the drupal subfolder, then you would need for that subfolder to point to where the content is. It's similar to what you do for a multi site installation. You can theoretically do this through mod rewrite, but it would be easier to create a symbolic link (symlink), ask your host.

Anisa.
made her first multisite today! :)

-----------------------------------------------------------
Kindness builds stronger bonds than necessity.

www.animecards.org - 18,000 card scans and counting!
-----------------------------------------------------------

isaac77’s picture

Thanks for your help!

Here's what I did:

- installed drupal into its own directory at webroot/drupal/
- created a directory webroot/drupal/sites/domain.com.test
- copied the settings.php file from sites/default into sites/domain.com.test and modified it to to connect to the database
- (this was the missing piece of the puzzle, which is not mentioned in drupal's install instructions) -> created a symlink called "test" in the webroot and pointed it to the directory /drupal From what i understand, this passes web browsers' request to drupal, which then sends requests on to the proper directory under "sites" based on the url

Seems to be working now. Thanks again everyone!

Anyone know where I can find instructions for making this test site into the real/live site once I get it working properly?

wmostrey’s picture

Hey isaac77,

You should ask your webhost to fix this for you. Ask them to set the DocumentRoot of test.sitename.com to the /drupal directory instead of the normal one. That should fix that problem.

If it doesn't, or they do not wish to do so, you could add the following to the index.php file of www.sitename.com:

if ($_SERVER["SERVER_NAME"]=="test.sitename.com") {
header("Location: http://www.sitename.com/drupal");
exit;
}

Alternatively, if you want to keep "test.sitename.com" in the browser window, you could try the following:

if ($_SERVER["SERVER_NAME"]=="test.sitename.com") {
echo "<frameset cols=\"100%,0\"><frame src=\"http://www.sitename.com/drupal\"></frameset>";
exit;
}

This is not clean in any way, so I'd strongly advise against it.

isaac77’s picture

Thanks for the advice, wmostrey

For now I'm content to just use a subdirectory (sitename.com/test) instead of a subdirectory. I got the webhosting company to create a symlink called "test" in the webroot and point it to the directory /drupal and everything seems to be working.

In general, I am a little confused about how requests for www.sitename.com are supposed get to /drupal/index.php in order for drupal to process them and spit out content.

I understand that if Drupal is installed directly into the web root, index.php would reside at /index.php and therefore would be called whenever a web browser is pointed at www.sitename.com. But what about if drupal is installed in its own directory? Would I need to set up a symlink? Or switch the DocumentRoot of sitename.com to the /drupal directory instead of the normal one ?

I'll need to figure this out before I go live with any sites. Would be grateful if you could clear this up!

wmostrey’s picture

Hey Isaac,

You are correct that most of the time the Drupal installation resides in the actual webroot, and thus Drupal's index.php is called. When Drupal sits in a subdirectory, and you want a custom index.php to redirect to that subdirectory, you just put the following into it:

header("location:http://www.sitename.com/drupal");
exit;

That's it. You could also make it a 301 permanent redirect, which google prefers:

header("HTTP/1.1 301 Moved Permanently");
header("location:http://www.sitename.com/drupal");
exit();

If editing the DocumentRoot is an option for you, feel free to do so as that is the cleanest way to do it. This disallows you from accessing any file outside the drupal directory to get accessed from the web ofcourse.

isaac77’s picture

Thanks, that clears things up. The install docs are not very clear on this issue; for less experienced users this can be confusing.

So is it usually preferable to just have drupal files in the webroot to begin with?

And in cases where drupal is in a subdirectory: is creating a redirect in an /index.php file (as you suggest) better than creating a symlink (from, say, a nonexistant index.htm file to /drupal/index.php) ?

Last but not least: how does one go about changing the DocumentRoot? In my case I'll prob have to ask the hosting provider, since I'm using a fairly cheap account for this project. But in general, is the DocumentRoot a parameter that is set in Apache (or whatever the webserver is)?

Thanks again!

vm’s picture

So is it usually preferable to just have drupal files in the webroot to begin with?

I don't know about preferable, but certainly easier.