Need Help in mod rewrite for subdomains

Discuss practical ways rearrange URLs using mod_rewrite.

Need Help in mod rewrite for subdomains

Postby ashishhbti » Tue Sep 09, 2008 2:35 am

Hi

I am using Catch-all-style for my domain by setting wildcard serveralias.

Now http://subdoman.domain.com mapping http://doman.com?user.php?login=subdomain.

I have created the Rules for this. these are following and working fine.

Code: Select all

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$ [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteRule ^.?$ user.php?login=%1 [L]




Now the problem is if sometype enter the url like http://subdomain.domain.com/(anything after that) will map to Error page


I have tried lots of thing(example below) but its not working


Code: Select all

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com/[.*/] [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteRule ^.?$ 404.php [L]




Please Help

Thanks
Ashish
ashishhbti
 
Posts: 1
Joined: Tue Sep 09, 2008 2:24 am

Postby richardk » Wed Sep 10, 2008 10:24 am

What's supposed to happen to "subdomain.domain.com/(anything after that)"?

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteRule ^$ /user.php?login=%1 [L]

RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$ [NC]
RewriteCond %1 !^(www|ftp|mail)$ [NC]
RewriteRule ^.+$ /404.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 6 guests

cron