Handling subdomains with wildcard domain names

Using a single web hosting account to host multiple sites

Handling subdomains with wildcard domain names

Postby ezee » Wed Jun 17, 2009 4:17 am

I have a shared hosting account where I can host as many sites as I can, they have given me a root directory where root .htaccess is uploaded and works for all domains (directories under root).

Now I want to create a virtual subdomain "links".anydomain.com which should point to a different directory under root, so I can use same links script for all domains using links.anydomain.com url.

I am looking for a mod_rewrite for this, if it is possible. The directory structure I have is somthing like this:

¦_ public_html
__¦_ .htaccess
__¦_ anydomain1.com
____¦_ .htaccess
__¦_ anydomain2.com
__¦_ anydomain3.com
__¦_ anydomain4.com
__¦_ anydomain5.com

etc.
ezee
 
Posts: 3
Joined: Wed Jun 17, 2009 4:03 am

Postby richardk » Wed Jun 17, 2009 11:05 am

You want one sub domain (links.*) for each of the domains to all go to one directory (eg. ./public_html/links)?

links.example.com --> ./public_html/links
links.example.net --> ./public_html/links
links.modrewrite.com --> ./public_html/links

Do you have any mod_rewrite already?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby ezee » Thu Jun 18, 2009 1:11 am

Yes exactly I want this but I dont have any mod rewrite till now, I have tried with few but that didnt work, like:

RewriteCond %{HTTP_HOST} ^links.(.*)\.(.*)$ [NC]
RewriteRule ^/try.html [L]
ezee
 
Posts: 3
Joined: Wed Jun 17, 2009 4:03 am

Postby richardk » Thu Jun 18, 2009 11:15 am

Have you set up DNS for the links sub domains?
What happens when you visit a links sub domain?

You are likely to have problems achieving this as mod_rewrite (in a .htaccess file) can not rewrite to a directory outside the current document root. So if the links sub domains get ./public_html/example.com/links or ./public_html/links.example.com as their default document root you will probably need more than mod_rewrite.

You can also try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^links\.(.+)$ [NC]
RewriteRule .* /links%{REQUEST_URI} [QSA,L]

in ./public_html/.htaccess, but i doubt it will work.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 22 guests

cron