[pmwiki-users] cleanURLand subdomain config.
jo at durchholz.org
Tue Apr 19 05:51:42 CDT 2005
jack marting wrote:
> PROBLEM: My host has told me that it is possible to have unlimited
> subdomains under my domain name but they will not tell me how to do
> it. But they did give me a hint quote "Technical information on how
> to do this is beyond our support, but as a good guide initial step is
> to add *.youdomain.com in your DNS configuration, then use
> mod-rewrite in a .htaccess file."
> QUESTIONS: 1--My DNS configuration has several categories
> (A,NS,CNAME,STR,MX, etc.). Which category should I put this
> "*.youdomain.com" into, or should I put it into all of them?
That depends on what exactly you want. Assuming you have just a single
machine at your disposal, A or CNAME are the relevant ones.
CNAME ("canonical name") is essentially a way to tell DNS "just take the
information on me from another domain". I.e.
*.yourdomain.com. IN CNAME yourdomain.com.
means: "for all domains in *.yourdomain.com, just take the info from
CNAME is best if the DNS information for all subdomains is going to be
the same. Otherwise, just create an A record.
> 2--Do they actually mean "*.youdomain.com" or do they mean
> "subdomain1.youdomain.com" then "subdomain2.youdomain.com" (etc.)?
That depends on what you want.
If you say *.yourdomain.dom, then your machine has the right and
obligation to do something sensible no matter what subdomain was
requested. That's the best course if all subdomains are just mirrors of
If you say
then the user will get a "host not found" error if he requests
baz.yourdomain.com. That's the best if foo.yourdomain.com,
bar.yourdomain.com, and yourdomain.com are different servers.
Note that I usually use a wildcard entry to "seal off the tree". I.e. my
entry for foo.yourdomain.com usually reads
foo.yourdomain.com. [additional DNS information]
*.foo.yourdomain.com. [additional DNS information]
This makes sure that if some confused user requests
www.foo.yourdomain.com, he'll get some information instead of just a
"host not found" message. (Some people prefer to just say
www.foo.yourdomain.com, on the grounds that subdomains like
mail.foo.yourdomain.com are reserved for future use. In practice, this
is rarely an issue, but it *can* be an issue.)
> 3--File structure, should the subdomain be a subfolder of the domain
> folder or could it be a main folder on the same level as the domain
Your web server will be fine with either choice, so it's your call.
Personally, I have found it best to create a separate folder for each
domain that serves separate content.
> 4--Which .htaccess file in which folder should the code be placed?
.htaccess applies to the directory that the server is serving a file
from, and to all subdirectories (unless overridden in a .htaccess on
that subdirectory - this override mechanism can be switched off by the
Apache main configuration, but I don't think your web hoster has done that).
> 5-The code, currently my .htaccess file contains only "Directoryindex
> pmwiki.php". Should it be before or after this line?
Directive order in .htaccess is relevant only if it's the same
directive. I.e. it doesn't matter whether DirectoryIndex or
RewriteEngine comes first, but it does matter which of two RewriteRule
directives comes first (the first directive can, for example, instruct
mod_rewrite to skip the second one if it matches).
> 6--What code, I have searched the web and found only one example of
> mod_rewrite used in a .htaccess file that was clear enough for me to
> understand. But I have been unsuccessful in getting it to work on the
> WAMP setup on my Windowsbox.
Then you probably didn't understand it.
That's not a criticism. Apache configuration is complicated, and the
best advice that I can give is: read and re-read the Apache
documentation until you understand it.
What helps tremendously is if you get to see the access and error logs.
(Unfortunately, Apache as of version 1.3 doesn't make it easy for the
webhosting provider to show you the error log.)
To the question behind your question: Normally, you don't need
mod_rewrite to redirect domains to their proper subdirectory. Instead,
webhosting providers give you a tool to directly configure which
subdomain should be served off which subdirectory ("DocumentRoot").
> 7--And finally, I have not been able to make the Clean URLs work
Hmm... it would help if you said what you tried and what the results
were. I'd like to improve the Clean URLs documentation.
More information about the pmwiki-users