catch all invalid subdomain to main domain page

Using a single web hosting account to host multiple sites

catch all invalid subdomain to main domain page

Postby lordx » Wed Jan 24, 2007 9:53 pm

Hi,

How can i do an auto-redirect of all invalid and non-existing subdomains to the main page.

example:

jasdguasd.example.com --> example.com
invalidsubdomain.example --> example.com
anyrandomsubdomain.example.com --> example.com

thank you
lordx
 
Posts: 5
Joined: Wed Jan 24, 2007 9:19 pm

Postby richardk » Fri Jan 26, 2007 9:52 am

Where do invalid sub domain requests go? To you main document root? What happens to valid requests?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lordx » Fri Jan 26, 2007 8:24 pm

richardk wrote:Where do invalid sub domain requests go? To you main document root? What happens to valid requests?


hi richard,

thanks for the help.

i need something to check if the subdomain is existing either real subdomain or virtual and must also coexist in harmony with this virtual subdomain mod rewrite viewtopic.php?t=2808

i need all invalid subdomains to redirect to http://example.com (main domain)


thanks again!
lordx
 
Posts: 5
Joined: Wed Jan 24, 2007 9:19 pm

Postby richardk » Sat Jan 27, 2007 2:58 pm

What do you mean virtual or real? What's the difference? Does one go to a sub dircetory? Or what?
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby lordx » Sat Jan 27, 2007 9:29 pm

richardk wrote:What do you mean virtual or real? What's the difference? Does one go to a sub dircetory? Or what?


hi richard,

real subdomain = a subdomain with real independent folder and subdomain created either via cpanel or manually.

virtual subdomain = the subdomain created with the mod_rewrite you game me

Code: Select all

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^(www\.)?domain\.com$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)-([^\.]+)\.domain\.com$ [NC]
RewriteRule ^$ /search.php?q=%3:%2: [L]


thanks!
lordx
 
Posts: 5
Joined: Wed Jan 24, 2007 9:19 pm

Postby richardk » Sun Jan 28, 2007 12:24 pm

Surely all subdomains that arn't real (created with CPanel) will be sent to the script. Mod_rewrite can't tell if query in the script will work, so it can't tell if it's invalid. If that's the case then you'll have to put the redircet in the script.

If this isn't the case, then explain how mod_rewrite is going to know which ones are invalid.
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 92 guests

cron