473,883 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

remapping dynamic subdomain

192 Recognized Expert New Member
Hi, I'm working on a web app and want to be able to offer my users a URL such as:

username.mydoma in.com

but have it map to:


FYI, I'm using codeigniter PHP framework, which should explain the above URL I need to map to.

I'm thinking this should be done with mod_rewrite, and I've tried various method to no avail. Any ideas on how to go about this?

Thanks for any insights!

May 27 '09 #1
6 4614
6,050 Recognized Expert Expert
I'm afraid you'll likely need access to the server's setup. No idea how you'd go about it, though.
May 30 '09 #2
192 Recognized Expert New Member
Hey Markus,

I have a vps, so I can do what ever. I'm just not sure exactly how to set it up. I added a wildcard domain, so all subdomains resolve, I just need the .htaccess to pick up the slack.

I actually had something working OK, but it redirected all subdomains. There are some I do not want redirected, like the main application, the demo version, the dev version, etc...all which are on their own subdomain.

So I need like a list of domains not to remap, and anything else should get kicked to a specific url.

Thanks for your reply!

May 30 '09 #3
6,050 Recognized Expert Expert
You can use the RewriteCond stuff for that. Something like this (untested):

Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{HTTP_HOST} !^sub1.site.com
I will do some testing to find the correct syntax.
May 30 '09 #4
192 Recognized Expert New Member
Hey no problem Markus, I appreciate your input. Ok, so it's fairly simple it looks like, I think the hardest part is figuring out how to phrase the google query to find what I'm looking for. I should have guessed it would be ! (not) this domain.

I'll see what I can work out with this. Thanks again!

May 30 '09 #5
6,050 Recognized Expert Expert
I think my above syntax is correct. For multiple sites, you could do this:

Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{HTTP_HOST} !^sub1.site.com
  2. RewriteCond %{HTTP_HOST} !^sub2.site.com
  3. RewriteCond %{HTTP_HOST} !^sub3.site.com
  4. # etc..
  5. # And then your rewrite rule.
May 30 '09 #6
221 New Member
i just spent all day trying to figure this one out for myself. i started off not even knowing how to use regex to feeling like a guru on this one. i pieced this information from the internet and it has nothing to do with codeigniter but it works for me. like i said i'm still a beginner so any critique of this code is welcome

Expand|Select|Wrap|Line Numbers
  1. #quietly redirect subdomain user profile requests
  2. RewriteCond %{ENV:REDIRECT_STATUS} ^$
  3. RewriteCond %{REQUEST_URI} !(/.+)$
  4. RewriteCond %{HTTP_HOST} ^([a-z-]+)\_([a-z-]+)/*\.thedomain\.com$ [NC]
  5. RewriteRule ^(.*)$ /profile/?first=%1&last=%2 [QSA,L]
  7. #ensure links go to the right place so css, js, etc work
  8. RewriteCond %{HTTP_HOST} !^([a-z-]+)\_([a-z-]+)/*\.thedomain\.com [NC]
  9. #also, if not a subdomain add www. for ssl cert (not completely necessary)
  10. RewriteCond %{HTTP_HOST} !^www\.thedomain\.com [NC]
  11. RewriteRule ^(.*)$ http://www.thedomain.com/$1 [R=301,L]
so http://ann-marie_jones.the domain.com
displays http://www.thedomain.c om/profile/?first=ann-marie&last=jone s

as long as a wildcard subdomain is set up, this code should be good to go
Jun 21 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

by: steve | last post by:
Hi I am writing an application which ideally requires the creation of subdomains dynamically via asp. However I want all the subdomains to point to 1 asp file, which I wish to use to figure out which subdomain has been typed in the url and to process it appropriately. I was thinking of 2 possible approaches and I am a bit 'cloudly' about both:
by: Leon | last post by:
How do I point a sub-domain to a sub-directory or .aspx page of my site using asp.net? I'm using a shared hosting service, that does not offer subdoman forwarding. however, you can write your own asp.net redirect code, and I just want to the best way to accomplish this task. it's possible that I may could have a 1000 subdomain names to redirect, but within the same application, to the same page
by: Bill Borg | last post by:
Hello, I have a couple web services that I use across my apps. My isp supports exposing them either via subdomain (e.g. services.mydomain.com) or subfolder (e.g. mydomain.com/services). Are there any implications for doing it one way versus another? Performance? Security? Thanks, Bill
by: perspolis | last post by:
Hi If I want to create subdomain for my site dynamicaly how can I do that with ASP.NET? or is it possib;e to create subdomain with IIS?? thanks
by: thomas | last post by:
Hello all, It seems like subdomain forwarding prevents ASP.Net session state from working correctly. Example: two websites http://www.jgphotographers.com/test and http://picturestore.newpicturestore.com/test - the first one works - the counter using session state increases every time the button is clicked. The second one uses subdomain forwarding with masking. The "picturestore"
by: Greg | last post by:
Is it possible for authentication using asp.net membership to persist from a site to a subdomain? The scenario I want to provide is: User browses to the page somesite.com and logs in. User clicks on link that points to the subdomain demo/somesite.com. Is it possible to retain the authentication information for the subdomain, so that there is no need to log in again?
by: Tina | last post by:
Our company domain, say, wombat.com needs to create several subdomains: support, training, and purchase are three of the subdomains needed. So when someone browses to //training.wombat.com they will be directed to the IP we have assigned. I have two questions: 1. how can I do this at design time? 2. how can I do this at run time from my asp.net code? Thanks,
by: a2rodger | last post by:
I am using the following function and parse_url() to attempt to grab the subdomain from my sites url function selfURL() { $s = empty($_SERVER) ? '' : ($_SERVER == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER), "/").$s; $port = ($_SERVER == "80") ? "" : (":".$_SERVER); return $protocol."://".$_SERVER.$port.$_SERVER; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } $url = selfURL(); $uri =...
by: devilsjunk | last post by:
Hello Everybody, In my web application I have created an interface where, if any user register then a subdomain will be created with the user name of the user link this manner E.G. :- http://subdomain.domain.com This works fine. Now if any user name contains special character like underscore then the subdomain only takes the character before underscore. For example if I register with devils_acc06 then the created subdomain URL is...
by: Josh | last post by:
I have a question about subdomains. I would like my website to have subdomains that essentially show my regular main website, except that the subdomain passes as a variable on all pages so that I can use the subdomain as a variable to customize details. For example, the home page at www.thesite.com would have a set of information displayed, but the subdomain (subdomain.thesite.com) would display certain additional details. Am I...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.