Main website and Subdomain Mobile Website (facing user directories issue) - php

I have main website on one domain and now I am working for m.domain.com (mobile sub-domain).
On my main website users register themselves and a directory is automatically created in website.
Now as I am working on different directory for m.domain, users register themselves and directory is created in m.domain, but it is not created in main website. So i am stuck.
I want to have common user's directories even when they login from main domain or m.domain.com
Here's image:

Do not use different directories for your domains.
You have (at least) two options:
configure your web server so that both domains (domain.com and m.domain.com) point to the same directory (e.g. virtual hosts - refer to your web server documentation)
configure URL redirects, so that any m.domain.com/page.php actually opens domain.com/page.php?mobile=1, where mobile=1 is a GET parameters.
In both cases, you have one set of PHP scripts, and the script can deliver the main/mobile content dependent on how it was called (either m.domain.com or due to a mobile GET parameter).

Related

Allow users to access their page on my site by using their own custom domain

I'm building a PHP MYSQL based site builder based on smarty templates where each site would have a folder which would contain all the site files such as html, assets and scripts. I want to add a option for my users to add their domain name in the backend for each site, point a dns record to my server and be able to access their folder on the server via their domain name
For example their url on my site would be www.sitebuilder.com/sites/example/
Their domain: www.exampledomain.com
When someone visits this domain, the index.html at the url would be shown.
I hope this makes sense, How do i achieve this? Thanks!

Dedicated domain for admin backend

I have Symfony2.8 application installed on my server. To make things easier, let's assume that in /very-long-path/web directory. I also have domain for this directory - eg. example.com. Page at example.com is accessible by all my users. Application has also backend for admins at example.com/admin. I think this is common configuration for many webpages.
What I want to do is:
Buy second domain eg. admin-of-example.com.
Disable access to the example.com/admin (or configure redirect to admin-of-example.com)
Make backend for admins accessible only via this second domain.
Is it possible and how? I completely don't know how to do that? Probably mod_rewrite?
What may be important? Symfony base on fron controller, therefore example.com/admin not directs to real folder - there is no /very-long-path/web/admin directory. Frontend for users and backend for admins are parts of one application, therefore I cannot move backend to other hosting/domain physically.
You can restrict routes to be matched only when the request is for a particular hostname: http://symfony.com/doc/current/routing/hostname_pattern.html

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!

How can I upload images to another host domain with php?

My admin panel is on test.com and I have functionality in my admin panel that allows the uploading of images. But the images must be uploaded to subdomain.test.com.
My server is CentOS 7.2 minimal and I installed DirectAdmin on server.
What is the best solution for this issue?
As per my understanding and experience it is not possible to direct upload, but following are some way to achieve this.
In your case, as you are looking to upload/save the images to sub domain created under that domain as mentioned by you. You can upload the file to your main domain and then move the images to your sub domain file using server root paths. It is easy to implement as you just want to save image on your subdomain.
Define some web service application on your subdomain which will read the images through bystream passed from main domain. i.e your main domain will call web services of subdomain to save the images. (It will require extra efforts)

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.

Categories