Can anybody suggest how do i attain the following (I could not prepare an answer using either mod_rewrite or virtualdocumentroot)::

1) Allow any subdomain on my small website, (* shouldn't give 404 error) AND

2) Be sure that the URL the user sees within the browser is exactly what he typed.

3) No redirects

(Thus, if user types, pages ought to be offered from corresponding directory. Now I do not worry about your directory structure I have to keep. Anything is okay as lengthy because it works. However, if he types, he shouldn't obtain a 404, but rather, should automatically get to a custom page online).

For instance, observe that any subdomain on works - like (Obviously Bing is Google and heck they are able to write their very own web server). But I am certain simple things like this is often completed in Apache.

Notes: 1) I'd rather not increaseOrmodify the apache config or .htaccess each time I give a valid subdomain.

2) From things i read on various threads, I'm able to use mod_rewrite for any catchall subdomain rule, however, the URL the consumer sees within the broser doesn't stay the same.




I've requested an associated question and also the solutions there appear to resolve the issue. Mentioning here just in case someone sees this:

The scenario you need to setup could be implemented with mod_vhost_alias for Apache httpd.

You need to simply produce a default virtual host to trap the non-existing subdomains, see An In-Depth Discussion of Virtual Host Matching for particulars.


<VirtualHost _default_:80>
  DocumentRoot /srv/www/custom_page
  # ...

UseCanonicalName Off
VirtualDocumentRoot /srv/www/%1/%2+

What you are explaining can be achieved with DNS, you'll also find to make use of wildcards to accomplish it.