473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

remapping dynamic subdomain

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

username.mydomain.com

but have it map to:

mydomain.com/controller/method/username

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!

Greg
May 27 '09 #1
6 4593
Markus
6,050 Expert 4TB
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
gregerly
192 Expert 100+
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!

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

Expand|Select|Wrap|Line Numbers
  1. RewriteCond %{HTTP_HOST} !^sub1.site.com
  2.  
I will do some testing to find the correct syntax.
May 30 '09 #4
gregerly
192 Expert 100+
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!

Greg
May 30 '09 #5
Markus
6,050 Expert 4TB
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.
  6.  
May 30 '09 #6
n8kindt
221 100+
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]
  6.  
  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.thedomain.com
displays http://www.thedomain.com/profile/?first=ann-marie&last=jones

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

1
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...
0
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...
2
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...
1
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
1
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...
0
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...
12
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...
3
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 =...
0
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. :-...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
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...

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.