Wildcard Subdomains
Permalink
I use Webmin and Virtualmin which makes it very easy to configure my server. So I'm fairly confident the DNS records have been set up for wild-card sub-domains correctly.
In a nut shell, what I would like to do is show people that gotohttp://username.mysite.com the content fromhttp://www.mysite.com/profile/username...
I thought this would be as simple as editing the .htaccess file, but no matter what the sub-domain is, it redirects me back tohttp://www.mysite.com.
For example, going tohttp://username.mysite.com/details... redirects me tohttp://www.mysite.com/details
Just to be clear, the address in browser's address bar changes back tohttp://www.mysite.com if I go tohttp://anything.mysite.com
I have a feeling this is related to the defined BASE_URL variable in the site.php file.
I have looked at the Domain Mapper Addon, but it doesn't handle wild-cards, so I don't think it would work in this case.
Any help would be greatly appreciated.
Thanks!
- IJ
In a nut shell, what I would like to do is show people that gotohttp://username.mysite.com the content fromhttp://www.mysite.com/profile/username...
I thought this would be as simple as editing the .htaccess file, but no matter what the sub-domain is, it redirects me back tohttp://www.mysite.com.
For example, going tohttp://username.mysite.com/details... redirects me tohttp://www.mysite.com/details
Just to be clear, the address in browser's address bar changes back tohttp://www.mysite.com if I go tohttp://anything.mysite.com
I have a feeling this is related to the defined BASE_URL variable in the site.php file.
I have looked at the Domain Mapper Addon, but it doesn't handle wild-cards, so I don't think it would work in this case.
Any help would be greatly appreciated.
Thanks!
- IJ
Good idea nteaviation, and that's part of how the multi-site hosting works, but I don't want separate instances of c5, and 'username' is the wildcard - a variable.
I hope I'm not being to confusing here while trying to explain this...
I just want it "clean-up" the URLs. So thathttp://www.mysite.com/profile/username... becomeshttp://username.mysite.com and everything after profile/username gets tacked on to mysite.com
So, like I posted before,http://anything.mysite.com/details... is equivalent tohttp://www.mysite.com/profiles/anything/details...
But c5 likes to completely redirect you to it's BASE_URL. So any domain pointed at your (for example) '/home/mysite.com/public_html' directory will get redirected to whatever is defined as BASE_URL. Heck, even if your BASE_URL points to a different server, you get redirected to the to whatever URL is defined.
I hope I'm not being to confusing here while trying to explain this...
I just want it "clean-up" the URLs. So thathttp://www.mysite.com/profile/username... becomeshttp://username.mysite.com and everything after profile/username gets tacked on to mysite.com
So, like I posted before,http://anything.mysite.com/details... is equivalent tohttp://www.mysite.com/profiles/anything/details...
But c5 likes to completely redirect you to it's BASE_URL. So any domain pointed at your (for example) '/home/mysite.com/public_html' directory will get redirected to whatever is defined as BASE_URL. Heck, even if your BASE_URL points to a different server, you get redirected to the to whatever URL is defined.
note that you have to both do the DNS settings and tell apache where to point that request after it receives it.
I've done this before on plesk by adding this to the ~/conf/vhost.conf file
ServerAlias *mydomain.com
if you're not on plesk then it should probably add something similar in your apache conf file in the vhosts setup.
I've done this before on plesk by adding this to the ~/conf/vhost.conf file
ServerAlias *mydomain.com
if you're not on plesk then it should probably add something similar in your apache conf file in the vhosts setup.
Thanks for the response Tony! You inspired me to make sure the apache2 server is working perfectly, as well as DNS and BIND. Which they are...
If I remove c5 completely, I can access (for example) '/home/mysite/public_html/index.html' by going tohttp://anything.mysite.com
However, if I have c5 on the site, it redirects me tohttp://www.mysite.com regardless of the sub-domain because of the BASE_URL.
Thoughts?
If I remove c5 completely, I can access (for example) '/home/mysite/public_html/index.html' by going tohttp://anything.mysite.com
However, if I have c5 on the site, it redirects me tohttp://www.mysite.com regardless of the sub-domain because of the BASE_URL.
Thoughts?
maybe hit up ryan to see if he has any ideas. I think he may have built the domain mapper.
If like you said: "you just want to clean up the URL", look at mod_rewrite. It can mangle your incoming URL into whatever you like and pass it off to c5. That is the way pretty URL's work. Put the mod_rewite configs in .htaccess or an apache conf. See:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html...
Problem is c5 is going to unmangle it back into "BASE_URL"+/anything/details, so you can get there using yourhttp://anything.mysite.com/details... but once you are there c5 will unmangle it back to "BASE_URL"+/anything/details
Food for thought... :)
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html...
Problem is c5 is going to unmangle it back into "BASE_URL"+/anything/details, so you can get there using yourhttp://anything.mysite.com/details... but once you are there c5 will unmangle it back to "BASE_URL"+/anything/details
Food for thought... :)
nteaviation, you hit the nail on the head.
That is exactly the issue I was trying to describe. This "unmangling" process, how do you prevent it and still use wildcards?
That is exactly the issue I was trying to describe. This "unmangling" process, how do you prevent it and still use wildcards?
Unfortunately, and I may be wrong, but c5 uses the "heck" out of that "BASE_URL" and "REL_DIR" to reference a whole slew of things from page URL's to the location of the core /concrete directory. Let me think on this some more :)
Thanks! :D
Hey Jessup,
Here's how I'd go about setting that up.
stop redirecting to the base url
/config/site.php
Then register an on_start site wide event - also in the site.php. In that event you can call a function that you can parse the HTTP_HOST variable and get your username, then redirect.
Here's how I'd go about setting that up.
stop redirecting to the base url
/config/site.php
define('REDIRECT_BASE_URL',false);
Then register an on_start site wide event - also in the site.php. In that event you can call a function that you can parse the HTTP_HOST variable and get your username, then redirect.
Excellent idea!
Thanks for the input. I will test this out and report back.
- IJ
Thanks for the input. I will test this out and report back.
- IJ
Correction:
define('REDIRECT_TO_BASE_URL', FALSE);
Works!
Now I have to modify my theme because it uses fontfaces, and you can't load those across different domains.
Now I have to modify my theme because it uses fontfaces, and you can't load those across different domains.
in config/your site.php? I don't think this is what your are looking for because you will need separate c5 installs in each 'DIR_REL'.