Subdomain and Subdirectory Addresses Both Work

Last night I created a subdomain on one of my sites named ldp. As it turns out both ldp.mysite.com and mysite.com/ldp present the same content. I never noticed this happening before and it really shouldn’t be allowed to happen.

My question is how do I insure that visitors going to /ldp get sent to ldp. instead.

Thanks,
Chris Short

I would just do it with PHP puting and index.php in the /ldp folder
<?
if($_SERVER[“SERVER_NAME”] != “ldp.mysite.com”) {
header(“location: ldp.mysite.com”);
exit;
}
?>

But, there’s an index.html file in that directory.

Make an .htaccess file in the /ldp directory with the following.

DirectoryIndex index.php index.html index.htm

<?
if($_SERVER[“SERVER_NAME”] != “ldp.mysite.com”) {
header(“location: ldp.mysite.com”);
exit;
}
else {
header(“location: ldp.mysite.com/index.html”);
exit;
?>

I think that should work. But the easier thing to do is just change your index.html to index.php and just stick the original code from my first post (without the else statement) at the very top of the file.

<?
if($_SERVER[“SERVER_NAME”] != “ldp.mysite.com”) {
header(“location: ldp.mysite.com”);
exit;
}
?>
<html>
<body>
blah blah blah…

Well it’s a mirror of another site that updates regularly. Any changes I make will be washed out in 12 hours at most.

I’m trying to eliminate /ldp/ as an option. That’s why I filed this under “Bugs”.

Well the other thing you can try is just killing that subdomain from “mysite.com”.
Then create a new SiteWorx account with domain “ldp.mysite.com”.

Or you can edit the Vhost manually via SSH and point to that folder. You will need to restart apache and I assume that is why Iworx doesn’t do subdomains that way.

What I meant by the SSH method of actually edit’n the conf files is discussed in this other recent thread:
http://interworx.com/forums/showthread.php?p=7254

Believe it or not that doesn’t seem to work.

Oaf,

When you say “that doesn’t seem to work”, were you referring to setting up another SiteWorx account using ldp.mysite.com as the domain or editing the vhosts file from the shell? Your best bet would be to create a SiteWorx account for that subdomain.

Socheat

Ok… It doesn’t really concern me that much. I appreciate everyone’s input and if it becomes a problem I’ll deal with it.

I’m on to my next issue:
http://www.interworx.com/forums/showthread.php?t=1164