I can see lots of hosted SAAS applications nowadays giving subdomains for their users, like if an app (say project management tool) is http://myapp.com and if a customers can have subdomains like
http://customer1.myapp.com , http://customer2.myapp.com and these urls can be reserved when the user is registering with the application.
I have a re-seller hosting plan and I want to the same thing, and my hosting plan has set wildcard subdomain and technically I can create any subdomain under my main domain. But my question is
with ruby/ rails
How to allow customers to pick their subdoamin by the time their
registration
what is the standard approach for a requirement like this
I'm planning to use rails 3.x.x
thanks in advance
I just recently did something similar, and what I did is that I configured the server to accept any subdomain and then redirect to a resource url. In your case, you will probably just route that subdomain request to the rails server. If you're using nginx, you would have something like:
server {
listen 80;
server_name dev.yoursite.com *.dev.yoursite.com;
root /path_to_your_site/public; # <--- be sure to point to 'public'!
passenger_enabled on;
rails_env development;
}
Then, in your app you can create a route with a subdomain constraint,
something along the lines of get '/' => 'users', :constraints => { :subdomain => /.+/ }, and handle that subdomain in your controller action using request.subdomain to find a matching user.
Keep in mind, that in your local environment, either list all your subdomain for testing or use lvh.me instead in your server config. If you will be using your own domain instead of lvh.me, don't forget to add that domain and subdomain in your hosts file. Also, for prod, don't forget to add wildcard subdomain record in your DNS.
Related
My domain provider uses only A records with IP addresses for root domains and Heroku doesn't accept that. I was told to use an .htaccess file to point mydomain.com to www.mydomain.com which is linked with a CNAME record and secured with SSL on Heroku.
I have no idea how this works and according to the apache doc, using an htaccess file reduces the HTTP server's speed. Instead I should write the configuration inside a <Directory> block in the main server configuration file.
Has anyone any recommendations? If I have to use the <Directory> block, where can I find the main server config file?
You could use a Heroku add-on like PointDNS, where you can point your root domain to Heroku via PointDNS Nameservers.
For steps, follow: https://www.mirrorcommunications.com/blog/how-to-correctly-point-your-domain-to-heroku, Option #1
I have a rails app and am using Heroku. I have SSL enabled.
https://www.mywebsite.example works just fine.
However, https://mywebsite.example does not work. What is the best approach to address this? Should I redirect https://mywebsite.example to the domain with ‘www’ and if so will the site still be secure.
Or should I enable SSL for https://mywebsite.example as well?
In the domain settings, I have:
Name: www
Type: CNAME
Data: blahblahblah.herokudns.com
Personally I would redirect www to the 'naked' domain and ensure as you have that SSL is installed on the 'naked' domain correctly.
You are then only maintaining a single instance of your site/app, rather than what Google and others will see as two individual 'sites'. (www and naked).
My site is multi-domain site using oa_domains module (in openatrium). All web is under SSL no exception.
Without SSL it works very well (multi-domain or single domain). Configured as https://www.drupal.org/node/2265627 (#4)
To be under SSL, With one domain setting, besides modification in .htaccess (redirect http -> https), I also add base_url to be https ://www.domain.com. This works well.
My problem is that Now I need to configure multi-domain using oa_domains module+SSL, I cannot use base_url anymore (for make SSL work), since the domains are different.
I was thinking to use if statement in settings.php. but some documents say that I should do with directories for different domains.
I then add sites/domain1.com and sites/domain2.com and copy the settings.php to both places but change them with different base_urls. However, it still does not work (errors, page not found, or cannot access the images of theme, plus lots of http:// in the script).
Can I use if statements in settings.php? how to know the current domain name?
Thanks.
I just put
$host = $_SERVER['HTTP_HOST'];
$base_url = 'http://'.$host;
for setting $base_url (settings.php) and
then create symbolic link that domain2.com -> domain1.com.
That's it!.
hosais
I have recently purchased a domain mydomainname.ca for my web mydomainname.com i would like the .ca to redirect to .com. I am very new to setting up web domains and such since my website was previously set up by another person.
There are multiple possibilities and as long as you don't specify the exact deployment, I'll explain all (hopefully) of them:
if you have only a domain and possibly a dns, route the .ca domain to your webserver, where mydomainname.com is located and then add virtual host alias to your .com webserver configuration
if you have domain and webhosting and the previous option is not possible (i.e. you don't have access to httpd config), use HTTP meta-redirect tag or Location: header to redirect to your .com domain
References:
Apache2 conf: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
HTML Meta tag: http://en.wikipedia.org/wiki/Meta_refresh
PHP header function: http://php.net/manual/en/function.header.php
Let's say I have an SSL secured domain at secure.domain.com.
I also have a web application (using silverstripe) at www.domain.com and another at app.domain.com (using CakePHP)
I would like specific areas of www.domain.com and app.domain.com to utilize SSL, and thus must somehow rewrite the paths using the subdomain with the installed SSL certificate.
So for example, secure.domain.com/ss/* should rewrite to www.domain.com/* and similarly, secure.domain.com/app/* should rewrite to app.domain.com/*.
The challenge, however, is that both www.domain.com (SilverStripe) and app.domain.com (CakePHP) have their own complex rewrite rules, and I can't seem to build an htaccess script that successfully retains the functionality of the respective applications...
FYI Assume I have the directory structure /public_html and webroots assigned to the apps as follows:
www.domain.com -> /public_html/subdomains/www
app.domain.com -> /public_html/subdomains/app
secure.domain.com -> /public_html/subdomains/secure
Has anyone accomplished something similar to this before?
The most elegant way is to simply symlink the SSL subdirectory to the apps folder, so they're basically the same directory.
/public_html/app
/public_html/subdomains/secure.domain.com -> /public_html/app
That is, if your host gives you this option.