![]() |
| Subdomain Redirect Script |
|
cptmorgan
|
I'm looking for a coldfusion script to redirect users to a different folder when they come in via a subdomain.
any help would be greatly appreciated. Thanks |
||||||||||||
|
|
|||||||||||||
|
Connie
|
Here is an example
<CFIF FindNoCase("sub1.domain.com","#CGI.SERVER_NAME#") GT 0> <CFLOCATION URL="/sub1"> <CFELSEIF FindNoCase("sub2.domain.com","#CGI.SERVER_NAME#") GT 0> <CFLOCATION URL="/sub2"> <CFELSEIF FindNoCase("sub3.domain3.com","#CGI.SERVER_NAME#") GT 0> <CFLOCATION URL="/sub3"> <CFELSE> You came to unknown domain. </CFIF> |
||||||||||||
|
|
|||||||||||||
| ETA on control panel |
|
comprug
Forum Regular
|
Is there any eta on when it could be doen in the control panel?
Thanks |
||||||||||||
|
|
|||||||||||||
| not working |
|
jason7655
|
any clue why the following wouldn't be working at the top of the application.cfm?
<CFIF FindNoCase("sub1.mysite.com","CGI.SERVER_NAME") GT 0> <CFLOCATION URL="/sub1"> </CFIF> |
||||||||||||
|
|
|||||||||||||
| I use Contains |
|
comprug
Forum Regular
|
I have to be honest, that I have never used "FindNOCase", but I have done redirection scripts like that in Application.cfm, and I would do this:
Thanks. But then again, I am a Ruby guy. |
||||||||||||||
|
|
|||||||||||||||
|
jason7655
|
Actually, it just doesn't execute. Eventually Firefox says the following:
Firefox has detected that the server is redirecting the request for this address in a way that will never complete. and if I do the following: <cfdump var="#CGI.SERVER_NAME#"> <cfabort> I get the correct subdomain. |
||||||||||||
|
|
|||||||||||||
| Got it! |
|
comprug
Forum Regular
|
Jason,
I'm glad you provided that error message. I have experienced that error many times, and the simple solution is to add this to the script:
Basically, what happens, is that as this is in the application.cfm, it is executed again when you are redirected. Since you did not specify the domain, it still contains the sub1 in the domain (I forget the name!?) , so it will execute the code again, redirecting you again - creating an endless loop. Don't worry though; I ALWAYS make that mistake probably just about every time I do redirects. |
||||||||||||||
|
|
|||||||||||||||
|
jason7655
|
It appears I got it working doing the following:
<cfif #CGI.SERVER_NAME# CONTAINS "sub1.mysite.com"> <cfinclude template="/sub1/index.cfm"> <!--- the cfabort is there so it doesn't execute the rest of the application.cfm ---> <cfabort> </cfif> Well see if I'm still able to do the other things I want to under that sub1. |
||||||||||||
|
|
|||||||||||||
| Subdomain Redirect Script |
|
||
|


