S
S
Shing2016-11-23 09:17:21
Apache HTTP Server
Shing, 2016-11-23 09:17:21

How can each mirror (alias) attach its main page?

Several more domains are attached to one domain by mirrors (alias).
It is necessary that each mirror (domain, alias) has its own index page.
But at the same time, it was possible to call the index.php file from the root (common home directory for each mirror).
If you select a folder under the main page, then the index.php request that lies at the root no longer works, since apparently it already considers the folder under the root.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.xyz$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain.xyz$
RewriteCond %{REQUEST_URI} !domain/
RewriteRule (.*) /domain/$1 [L]

If you do
DirectoryIndex domain.html
That because htaccess is common to all mirrors, it turns out that this page becomes the main one for all domains, but should be unique for each.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeniy Volf, 2016-11-23
@Wolfnsex

I have two options:
1. Enter into index.php itself a check for the current URL/Domain and the absence of additional. parameters and make a simple type construction

if ($_SERVER['HTTP_HOST'] == 'domain1.com')
{
    require('domain1.html'; exit;
}
//Остальной код

Or, try something like this:
<If "%{HTTP_HOST} == 'www.example.com'">
DirectoryIndex domain.html
</If>
*I can't vouch for the correctness, perhaps the comparison operator for equality in .htaccess is written somehow differently... The
example is taken from here, Canonical Hostnames section .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question