R
R
rinaz222020-05-28 11:53:05
PHP
rinaz22, 2020-05-28 11:53:05

How can I include files using php?

Hello. I send all requests to 1 file for processing home.php. This file contains conditions and so on.
There are folders with other pages and I want these pages to open as a subdomain, i.e. a file located on the main domain as page/info.php opened as info.site.ru . To do this, I set the settings so that requests from subdomains go to the main domain (and from there to the home.php file).
In home.php I check if it's a subdomain, and if so, load the page with include "page/info.php";
The page is loaded, but the rest of the files (pictures, styles, etc.) needed for this page are not.
How can it be solved? Is it possible to somehow specify in htaccess that files from subdomains are loaded, for example, from the main directory? You cannot create a separate subdomain, because. there will be other pages and they need to be managed through the admin panel (self-written).
I don't know if I wrote everything clearly, if you ask anything.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alams Stoyne, 2020-05-28
@alams_stoyne

I solved the problem like this:

  1. Created *.dou-nn.ru alias for the main domain dou-nn.ru (i.e. entered any subdomain on the main site)
  2. Next check $_SERVER['SERVER_NAME'] for valid subdomains
  3. Next, loading the necessary data (I use a database) depending on the url after the domain
  4. Depending on the domain, I loaded one or another design template

N
Nikolay Panaitov, 2020-05-28
@Picknice

в тег <head> добавляешь <base href="https://site.ru/"> - где site.ru твой основной домен
По идее если ты везде использовал путь относительно (например, <img src="images/logo.png">), то должно все работать правильно!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question