Run app.mydomain.com as mydomain.com/app on Heroku - php

I have a PHP app running on Heroku (app.herokuapp.com) and it is currently being pointed to app.mydomain.com. My question would be:
Is it possible to run app.mydomain.com at mydomain.com/app? Basically I would like the app to run in a subfolder as opposed to a subdomain.
Any help is greatly appreciated.
Thank you!

You cannot in a clean way (you could with iframes, but shouldn't go that way) point your application to a subdirectory in an other application.
That is because when not using the x.herokuapp.com domain name, you need to use custom domains. These relies on DNS entries to point to an application or an other.
And you cannot create DNS entries for a subdirectory.
What you could do though, is package one application at example.com, inside which you display whatever you want for the / url, and you load your application at the /app url.

Related

Laravel Forge - multiple sites on the same server

I have over the past months tried to learn myself about php/laravel. I have made some laravel hobby apps which i was thinking of putting on a server, so i could use them.
I am using digitalocean for the server and laravel forge for easy deployment.
My problem is that on laravel forge it says that i can add sites, but how do i add more than one site?
There is three fields to fill in: Root Domain, Project Type and Web Directory. What do i type in these fields and how do i access the site afterwards?
Root Domain: This is the domain (web address) that you want to be associated with your site (e.g. example.com).
Project Type: This is the type of application that you're wanting to be hosting. In your case it will be General PHP / Laravel.
Web directory: This is the folder of your app that you want to use as the web root. In your case this should be public/ (unless you've moved/renamed the directory or you've moved you index.php out of that directory which I don't recommend). It is generally good practice to have your web root in a sub directory so that you can easily prevent access to sensitive information by placing it in the root directory or you app.
With a Laravel site you should almost always only have to fill out the root domain field as the rest are set for Laravel by default.
Forge comes with a "default" site set up so that you can access your site with just your ip address of the server, however, if/once you've got your domain it is recommended that you delete this and then add your site/app with the domain.
To add another site you would just need to:
Point the A record of your domain to the IP address of your forge server
Fill out the form for adding a new site (in Forge)
On the next page set up forge to pull your app from your git repo.
This tutorial should give you a quick overview: https://laracasts.com/series/server-management-with-forge/episodes/13
It is part of a series should you want/need more information but please note that some of the videos are over 2 years old so some minor things might be a bit different.
Hope this helps!

Set url to level above installation directory Wordpress

I don't know if it is even possible so that's why I put my question here.
We have a webserver running a PHP application build within the Yii-framework and we have also integrated Wordpress into that application.
The root contains the Yii-application and a dir with the wordpress installation. Now I would like to know if it's possible to create a page and have it a url outside it's installation dir.
An example:
domain.com shows the Yii application index
domain.com/blog shows the Wordpress homepage
Now I want to create domain.com/foobar and the page foobar comes from Wordpress.
Is it possible and how?
Kind regards,
Pim
Your server will have been setup with your domain name. I don't know if you are using a hosted service, or a cloud based option, but either way you should be able to tell your web server to load different index.php files based on the URL.
Every single web request comes through your web server. You can tell your web server to load different php files depending on the http request URL.
For example, when you setup your sever with domain.com you would have had to (or in most cases its the default) tell your web server to route all domian.com requests to /public/index.php
Following this logic, if you want to load a different index.php file from a different URL, you just have to set this up in your web server. So domain.com/foobar would point to /some/directory/public/index.php
The way you do this very much depends on your server and if you have some server admin software installed e.g. cPanel.

Route/create a sub-domain in CakePHP, how to

I've tried solutions as such, but they don't see to address the problem Im at.
How to create a sub-domain in CakePHP?
I have a CakePHP app in publichtml/lastroarte.com running ok. I went to my DNS and created for a subdomain entries for sandbox.lastroarte.com a test subdomain for the new version of my which we'll be upload the new app.
If I browse to the subdomain now, it redirects me the home page of my domain, still displaying the url sandbox.lastroarte. I've found entries for the pages in the Routes file of Cake, although I have not found way to say a subdomain should display the index of its own folder (public_html/sandbox.lastroarte.com). Am I doing the right approach? How to achieve this?
Appreciate your answers.
(Assuming you are running apache as your web server)
You have created a sub-domain, but have you created sites-available and sites-enabled files and restarted apache?
If you are using your host's control panel it will do this for you, but you will need to associate your public_html/sandbox.lastroarte.com directory to the sandbox.lastroarte.com sub-domain.
In short this doesn't sound like a Cake routing problem, it sounds like apache is routing traffic from sandbox.lastroarte.com to lastroarte.com.

Redirecting to mobile subdomain in a CI application

I have a web app of which I would like to create a mobile version with jQuery Mobile. The existing application is built in CodeIgniter; I'll be using the same controllers, models where I can; (especially models since I'll be needing the same data anyway, might have to write new controllers).
I'm a bit confused as to how to get started. I want to put my mobile version on a subdomain (m.myhost.tld), however.. since my app is at www.myhost.tld and I don't feel like copying it all over to another folder and maintain two, I'm a bit confused.
I know I can use the User Agent library in CodeIgniter to detect mobile browsers and load views accordingly; I just don't know how to get this working with a subdomain. Do I need to customize my app/config/routes.php file here, or can I fix this with some .htaccess magic? I have next to none experience with .htaccess though. The only thing I know is how to remove my index.php from CI apps, and that's a copypasta snippet.
EDIT: I wonder if I can use a tutorial like this one to do what I want to do? It seems to be doing more or less the same thing, just with dynamic usernames instead of a simple 'm.'
EDIT 2: Some more information, I guess.
Say I detect mobile browsers using the User Agent library included with CodeIgniter. I want to direct these browsers to m.myhost.tld. However, the content that I want to display on the mobile website comes from a controller called mobile which I can also access through www.myhost.tld/mobile/; so my question is if there is a way to route a URL like.. for example www.myhost.tld/mobile/about to m.myhost.tld/about. I'm not even sure if this is possible, teehee. Still learning!
I'll be grateful for any advice you can give me. Thanks a lot!
If you want to share the same files in different hosts, you must assign the document root folder of your sites in your web server, this is an explanation for static files, but is the base to you understand.
browser -> host:z.y.xxx[ip.ip.ip.ip] -> web server -> read filesystem : document root + browser request path
so if your document root is:
/hosting/http/z.y.xxx/htdocs
and the request is /path-to-static/index.html the server try to read:
/hosting/http/z.y.xxx/htdocs/path-to-static/index.html
In conclution, you create the new host m.mysite.tld in your web server and you change the document root as the same of the you www.mysite.tld also you could use directives of host alias, like Apache ServerAlias directive. Have lot of documentation to how you could configure a web server.
You could handle the host name in php with $_SERVER['HTTP_HOST'] variable.
If you could specify more, I could help more.
have a nice day

How to dynamically create subdomains

I want to dynamically create new sub domains on my website. i mean if you have example.com then you dynamically create sub.example.com .
i looked on google and there was nothing really good. i downloaded some scripts but they were all not working. my website is based on php so please if there is anyway i can do it in php tell me, and also if it can be possible with python then that is awesome!.
You need to setup a wildcard subdomain. Basically, anything.mysite.com will resolve to mysite.com. At that point it's up to your code to kick in and serve up the proper content depending on what subdomain the user is looking at.
http://www.google.lk/search?q=wildcard+subdomain
You can't do this unless you have permission to alter the DNS server for your domain.

Categories