Forum Moderators: phranque

Message Too Old, No Replies

Rewriting arbitrary subdomains to subdirectories [redux]

         

compooter

11:40 pm on Mar 21, 2005 (gmt 0)

10+ Year Member



I recently found the rewriting arbitrary subdomains to subdirectories thread [webmasterworld.com] (thank you!) and was wondering if it could be extended. If this is possible, it's likely to only take one additional line, but I'm lacking the skill to quickly figure it out.

Would it be possible to do this /only/ if the directory exists? Reason being: some domains I work on have wildcard DNS so that all subdomains resolve with a status 200 Ok. I'd like to throw a 404 if the subdomain/directory does not exist. I know you can do checks like this:

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d

but is it possible to add a conditional that checks in this manner:

RewriteCond %1<>%3 !^(.*)<>\1$ [NC]

for an existing directory?

[edited by: jdMorgan at 12:02 am (utc) on Mar. 22, 2005]
[edit reason] Repaired link to original thread. [/edit]

jdMorgan

1:05 am on Mar 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can isolate the requested subdomain, convert that to a filepath by prepending %{DOCUMENT_ROOT}, and then do the "check for exists".

Well, I think that's what you're after here...

Jim