K
K
Kn942342019-10-26 11:31:25
Nginx
Kn94234, 2019-10-26 11:31:25

How to connect a site in a subdirectory?

Good afternoon! There is a website, let's say example.ru. PHP mode is CGI. CMS - author's (the studio that made the site). I want to make a regional site through subfolders. I made a copy of the site and copied it to the folder: example.ru/almaty.
Then I changed $site in the config (config.php):

$site = "example.ru/almaty";
$host = "localhost";
$user = "...";
$passwd = "....;
$dbname = "....;

Then in the database connection script db.php added - almaty:
include_once $_SERVER['DOCUMENT_ROOT']."almaty/config.php";

Then I changed the index.php boot file a bit:
include_once $_SERVER['DOCUMENT_ROOT'].'/almaty/config.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/almaty/db.php';
include_once $_SERVER['DOCUMENT_ROOT'].'/almaty/classes/Core/Core.php';

and changed the variable
$root = $_SERVER['DOCUMENT_ROOT'].'/almaty';- in it, which is further used to determine the location of files and folders, such as:
include_once $SITE->root.'/lib/lib.php'; или
include($root."/components/".$components."/frontend/main.php");

Basically, he did it all. But on request example.ru/almaty - 404 error crashes and redirects to the main site.
At the same time, in index.php I added the command "echo $root;" - for check. So, when the error window opens, it is displayed there . I $ _SERVER['DOCUMENT_ROOT'].'/almaty'.
thought it might be in the nginx settings. After all, the use of domains is prescribed there, so that the database can be connected in a subfolder - you also need to register something there.
And yes - I did not create a separate database, but took the one that is used by the subdomain (almaty.example.ru).
Does anyone have an idea or insight into where to dig next to launch a site in a subdirectory?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Kn94234, 2019-10-28
@Kn94234

In general, I figured out - in the php file there was a protective check against copying the site. It was enough to tweak the code a little and everything loaded. Found a glitch with the help of commenting. I commented everything out, and uncommented it one block at a time until I saw which code returns a 404 error. And there it immediately became clear that this was a check.

A
Alexander, 2019-10-26
@Panascanic

I will not answer to the cashier, because I tried to do the same on WP - it took 2 minutes along with screenshots.
Step 1
Step 2
Step 3
"Kagbe" and that's it. It's more about the "author's CMS" and the appropriateness of use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question