Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-04-15 12:09:08

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

false sub domains working...what, why, how ?

I don’t know if this has been the situation for a long time and I just noticed it while trying to get my dev stuff setup on the mac, but if you type in any address like whatever.mydomain.com (at wion) it goes to mydomain.com. Why? Shouldn’t that be a 404 error? If you type it in the form mydomain.com/whatever then it is a 404 error. What gives?

I did do some recent editing to my .htaccess, here it is currently…

RewriteEngine On

# The following rules redirect all URI calls using the www to go to the same location without it.
# Never remove these rules!

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC]
RewriteRule (.*) http://mydomain.com/$1 [R=301,L]

# And this stuff is Textpattern default stuff, needed for CLEAN URLs, among other things.
# Never remove these rules!

#DirectoryIndex index.php index.html
#Options +FollowSymLinks
#RewriteBase /relative/web/path/

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^(.+) - [PT,L]

 RewriteRule ^(.*) index.php
</IfModule>

#php_value register_globals 0

The purpose of that first rewrite condition, or so I thought, is to force all calls using “www” to go directly to http://mydomain.com, but maybe it’s not right?

Last edited by Destry (2007-04-15 12:10:15)

Offline

#2 2007-04-15 13:42:12

Walker
Plugin Author
From: Boston, MA
Registered: 2004-02-24
Posts: 592
Website

Re: false sub domains working...what, why, how ?

Correct.

But for those other domain, you’ll have to rewrite them as well…..

The reason whatever.domain.com works is because you got wildcard dns active (which I think is a good thing…)

Do something like this, instead, to rewrite all subdomains:

RewriteCond %{HTTP_HOST} ^(.*)\.mydomain\.com [NC]
RewriteRule (.*) http://mydomain.com/$1 [R=301,L]

warning: not tested :)

Last edited by Walker (2007-04-15 13:42:26)

Offline

#3 2007-04-15 16:15:51

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: false sub domains working...what, why, how ?

Thanks Walker. That means it’s been that way for quite a long while then. :)
The changes I made to my .htaccess was removal of some old lines, which are not reflected in the code above.

I guess I see what you mean about leaving it…somebody types something wrong, they go to the home page.

Offline

Board footer

Powered by FluxBB