Forum Moderators: phranque
i want to use subfolders to work like subdomains
i have setup wildcard dns.
and set some .htaccess code
and all working fine.
recently i faced new problem in wildcard dns. if some one made folder which consist one more digit (i.e. just4you.domain.com) then it is redirected to domain.com.
my htaccess code is :
-------------------------------------------------
RewriteCond %{HTTP_HOST} ^([^.]+).domain.com
RewriteRule (.*) /%1/$1 [L]
-------------------------------------------------
so i want to parse digit in url and if so then it will be redirected to given subdomain.
if anyone knows this stuff then please help me ASAP
THANKS,
-ENIL
However, I'm surprised that you are not having problems with an 'infinite' redirection loop. If you are, this recent thread [webmasterworld.com] demonstrates a solution.
Jim
RewriteCond %{HTTP_HOST} ^[^0-9]*[0-9][^0-9.]*\.example\.com
RewriteRule .* http://www.example.com/no_digits_allowed.html [R=301,L]
For more information, see the regular-expressions tutorial cited in our forum charter [webmasterworld.com].
Jim
code you gave for digit parsing is not working.
it redirects example.com index file. not to the sub domain.
i used this second line instead you specified
-----------------------------------
RewriteRule (.*) /%1/$1 [L]
-----------------------------------
whenever i try to browse, it redirect to main file
i.e. suppose i try, 123.example.com then it redirects to example.com's index file. and i want it redirect to 123 folders's index file.
in short, i want this,
123.example.com => example.com/123/index.htm => in browser, path should be 123.example.com
im007.example.com => example.com/im007/index.htm => in browser, path should be im007.example.com
my previous code is working for only for alphabets. but it fails when digits are encountered and it does not redirect and page can not be found occured. previous code is:
-----------------------------------------------
RewriteCond %{HTTP_HOST} ^([^.]+).domain.com
RewriteRule (.*) /%1/$1 [L]
--------------------------------------------
pls let me know ASAP
ENIL
i now got perfect solution.
i know i have messed up the code now i got final and superb one which is perfectly working on my way. i used some part of your code.[^0-9]
here it is:
--------------------------------------
RewriteCond %{HTTP_HOST} ^([^.]+)[^0-9.]*.example.org
RewriteRule (.*) /%1/$1 [L]
--------------------------------------
no looping. no page not found error. sub domain with digit is nicely redirected.
i am very thankful to you. you provided me nice code.
Thanks again,
ENIL
[edited by: jdMorgan at 8:35 am (utc) on Dec. 28, 2006]
[edit reason] example.org [/edit]