Create a subdomain and point it to a folder via Godaddy API - godaddy-api

I am adding an 'A' Record using Godaddy API, a subdomain is created but it is not pointing to the folder where I need. Please help to do the same, what thing I can use in API to point my subdomain.
https://api.godaddy.com/v1/domains/tfedtech.com/records/?domain=domain.com
[{"data": "148.66.122.111","name": "test","ttl": 10800,"type": "A"}]

I found its solution and Used Cpanel API for this
https://api.docs.cpanel.net/cpanel/introduction/
$resonse = $this->cpanel->uapi->post->SubDomain->addsubdomain(
array(
"domain" => "$subdomain",
"rootdomain" => "tfedtech.com",
"dir" => "public_html/panel.tfedtech.com",
"disallowdot" => 1
)
);

Related

Subdomain routing with devise not working on heroku

I have defined a few types of users using devise (members, company_users, etc) and I'd like to use different subdomains for the login pages of each type of user.
I've referred to this railscast in order to implement the matching of the subdomain and redirect to the appropriate action. My routes.rb file looks like this:
devise_for :company_users, :controllers => { :registrations => 'company_users/registrations', :sessions => 'company_users/sessions' }
devise_scope :company_user do
constraints Subdomain do
match '/' => 'company_users/sessions#new'
end
end
And my lib/subdomain.rb file:
class Subdomain
def self.matches?(request)
request.subdomain.present? and request.subdomain =~ /\Acompanies\z/
end
end
Locally, it works perfectly. I've tested using companies.lvh.me:3000 (as the same railscast suggests) and it really redirects to the correct login page.
In order to try and make it work on Heroku I have added the domain, using heroku domains:add companies.mydomain.com, and I have added a new CNAME record on my DNS server, pointing to my Heroku application.
However, when I try to access companies.mydomain.com it redirects me to the root path, and not to the correct login page. I'm kind of clueless of what's happening. Any help will be appreciated.
This happen when the tld of your domain is different from tld of the heroku domain.
Mine is .com.br and I have to add config.action_dispatch.tld_length = 2 to production.rb, so Rails can parse the URL correctly and redirect to the right subdomain.

Install drupal in a directory beside an existing website

I want to Install a drupal website on the server in a subdirectory to use some of it's features for my main website, I dont want the installation affect the current website in any way.
the actual reason for doing this is that for example I would be able to use news section of drupal for main website.
so for instance, I install drupal on "drupal" subdirectory like www.mydomain.com/drupal , then when I configure and run the news section it will be like www.mydomain.com/drupal/news, what I want is when a user goes to www.mydomain.com/news, it loads www.mydomain.com/drupal/news instead.
I'd really appreciate any proper approach and suggestions to achieve this.
If I correctly understand your question that you want to have URLs like:
http://example.com/news/headline-test
But using Drupal's URL http://example.com/drupal/news/headline-test to provide the content of the first URL, you should use Apache rewrites.
Here is an example:
Add this to your top .htaccess folder (http://example.com/.htaccess - not publicly accessible yes):
RewriteEngine on
RewriteRule ^news/(.*) drupal/news/$1
See the Apache rewrite document for more examples/help.
Drupal cannot take over any folder if there is another file exists or it's pointing to another folder. But in this case, both of your http://example.com/drupal/news/headline-test and http://example.com/news/headline-test URLs will show the same content.
Do not edit Drupal's $base_url setting. Let Drupal figure it out. Also, add some robots.txt disallows to prevent content duplication. Block drupal's native URLs.
Take a look at redirect module.
OR
Create a custom module with hook_menu implementation
function MY_MODULE_menu()
{
$items = array();
$items['news'] = array(
'title' => 'news redirect',
'type' => MENU_CALLBACK,
'access callback' => TRUE,
'page callback' => 'drupal_goto',
'page arguments' => array('drupal/news'),
);
return $items;
}

API subdomain for Heroku app, is it possible?

I am trying to build an API and I am concerned that all my resources will either not be accessible with the api.myapp.com domain or that they will "live" with the wrong uris.
I have added the CNAME for my domain name to point to my Heroku app.
(ex: browsing to www.myapp.com takes you to https://myherokuapp.heroku.com)
I would like to set up an API subdomain, so that a GET to
https://api.myapp.com takes you to https://myherokuapp.heroku.com/api/v1
The best scenario would be that a POST to https://api.myapp.com/accounts/12345 would create a new account. Is that even possible?
(I know that subdomains (eg: mysubdomain.myappname.heroku.com) are not possible with Heroku)
I believe the answer could be in three different places:
Something to do with DNS provider forwarding configs (maybe
something to do with "A" records).
Something to config in Heroku, possibly a paid add-on to handle domains/subdomains.
Handle all subdomains within my app.
If you want to differentiate between api.mydomain.com and www.mydomain.com and have different controllers for your API requests then you could certainly use Rails routes constrained to your api subdomain to handle this
constraints :subdomain => "api" do
scope :module => "api", :as => "api" do
resources :posts
end
end
which would then use the posts_controller.rb in the app/controllers/api folder of your application.
You'll then have both www.mydomain.com and api.mydomain.com added a custom domains for your application and then the routes will take care of the rest.
You might also want to look into the Grape Gem for helping build your api

Mount an engine on subdomain Rails 3.1

I am doing some experiments with Mountable Engines. First i need your opinion for a scenario, Is it a good idea that we make "chunk of large modules" in an application as "mountable engines".
I tried this it works great, In mountable engine we can access models of app globally and in app we can access engine models with module prefix. So it works great for me.
Now came to original question:
I want to mount an engine to a subdomain, so that every request with specific subdomain should be served by that specific engine. I used this code.
root :to=>'dashboard#index'
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
In this case mydomain.com and admin.mydomain.com goes to dashboard controller. If i change the preferences like that
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
root :to=>'dashboard#index'
In this case mydomain.com and admin.mydomain.com goes to engine specific root controller.
How can we accomplish this scenario and mount an engine on specific sub-domain?
I accomplish the task by using these route entries:
scope :subdomain => 'www' do
root :to=>'dashboard#index'
end
scope :subdomain => 'admin' do
mount MyAdmin::Engine => '/'
end
Working with Rails 3.2.12 and ruby 1.9.3-194 I came to a different solution that also works locally for avoiding the www. subdomain issue while allowing there to be an Engine at a certain subdomain.
get "home/index"
constraints :subdomain => 'store' do
mount Spree::Core::Engine, :at => '/'
end
root :to => 'home#index'
I could totally be wrong but it's working so far.

What to choose for Yii based website: subdomains pointing to modules or separate yii-applications

I'm making a website on yii which has several separate parts, each on it's own subdomain like themes.example.com, events.example.com etc with main page example.com where these parts are listed. I will also need to authenticate users across subdomains. So i'm thinking what would be better: making each part as a yii module or making a separate yii application for each of these parts?
I think in your case it would be better to use modules. At least to have a single webroot directory. Using separate yii application would be appropriate for console part of your project.
See this link for more information: The directory structure of the Yii project site
Well,
The features you are trying to accomplish from Yii its called "Parameterizing Hostnames". You need to create a module based structure in Yii.
At first you need to create a virtual host from apache and redirect that to your Yii project. On you Yii framework you need to change the URL manager from config.
'components' => array(
...
'urlManager' => array(
'rules' => array(
'http://admin.example.com' => 'admin/site/index',
'http://admin.example.com/login' => 'admin/site/login',
),
),
...
),
To know more about Parameterizing Hostnames