mod_rewrite to rewrite HTTP_HOST (subdomains)
Moderator: General Moderators
mod_rewrite to rewrite HTTP_HOST (subdomains)
I'm trying to use mod_rewrite to send users to a sub-directory for certain sub-domains. Is there a better way to do this (w/out mod_rewrite)? If not, than how do I rewrite the HTTP_HOST portion of the uri?
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
OK, so this rule works:
But it attaches /blog to the end of the URI in the URL, so I type in blog.mysite.info, and then it redirects me to http://blog.mysite.info/blog. Is there any way to make it not show the /blog part?
Code: Select all
RewriteEngine On
# Skip www.mysite.info
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTP_HOST} ^([^.]+)\.mysite\.info
RewriteRule ^/(.*)$ /vservers/mysite/htdocs/%1/$1 [L]Nevermind... this works.
EDIT: now... anybody have any ideas on how to keep requests from http://www.mc2design.info/wiki and http://www.mc2design.info/blog from resolving? I only want those to be accessible via the subdomain. I can't figure out how to make it work. 
Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(wiki|blog)\.mc2design\.info
RewriteRule ^(.*)$ %1/$1 [L,QSA]
Last edited by Luke on Fri Mar 02, 2007 4:47 pm, edited 3 times in total.
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
Surely your host provides a control panel of some sort. (cpanel for example)
I.e.: http://jefs.com/nick/Clipboard01.jpg
I.e.: http://jefs.com/nick/Clipboard01.jpg
Alright, I've got another question related to this...
I've got a subdomain set up at blog.mc2design.com and a subdomain set up at blog.mc2design.info. If blog.mc2design.com is pointed at mc2design.com, what would I have to do in order for somebody to type in blog.mc2design.com and have them resolve to blog.mc2design.info, but never know about it? Is it possible? I've never been able to get this to work.
I've got a subdomain set up at blog.mc2design.com and a subdomain set up at blog.mc2design.info. If blog.mc2design.com is pointed at mc2design.com, what would I have to do in order for somebody to type in blog.mc2design.com and have them resolve to blog.mc2design.info, but never know about it? Is it possible? I've never been able to get this to work.
-
nickvd
- DevNet Resident
- Posts: 1027
- Joined: Thu Mar 10, 2005 5:27 pm
- Location: Southern Ontario
- Contact:
So, you want both .info and .com to resolve to the same ip address, so that all requests get sent to the same server?
Add a new entry in your dns system for .info pointing to the same ip address, you will have to ensure that you can add a domain to your hosting account (some hosts charge per month for this).
Other than that, I can't think of anything else you'd be required to do.
Add a new entry in your dns system for .info pointing to the same ip address, you will have to ensure that you can add a domain to your hosting account (some hosts charge per month for this).
Other than that, I can't think of anything else you'd be required to do.
Tell me if this resolves for you:
http://blog.mc2design.com/
http://blog.mc2design.com/
