Как я могу разделить основной домен и дочерние домены использовать мод переписать с файлом htaccess - PullRequest
0 голосов
/ 02 мая 2018

Я хочу перенаправить субдомены на моем сайте, если они запрашиваются, но если я не запрашиваю, я хочу перенаправить их в другой домен. Я нашел некоторые коды при поиске в Интернете, но я не улучшился. Если я не могу сказать, что я хочу сделать, я хочу, чтобы следующий URL и структура файла были такими же, как я показал.

public_html/
|____.htaccess (main htaccess)
|____index.php (php empty)
|____mainDomain/
|     |_____.htaccess (without subdomain htaccess)
|     |_____index.php
|     |_____public/
|     |      |____.htaccess (application htaccess)
|     |      |____index.php
|____subsDomain/
|     |_____ucgen/
|     |_____testFolder/

основной доступ:

RewriteCond %{ENV:REDIRECT_SUBDOMAIN} =""
RewriteCond %{HTTP_HOST} ^([a-z0-9][-a-z0-9]+)\.metehanboy\.com\.?(:80)?$ [NC]
RewriteCond %{DOCUMENT_ROOT}/subsDomain/%1 -d
RewriteRule ^(.*) subsDomain/%1/$1 [E=SUBDOMAIN:%1,L]
RewriteRule ^ - [E=SUBDOMAIN:%{ENV:REDIRECT_SUBDOMAIN},L]

RewriteRule    ^$    mainDomain/    [L]
RewriteRule    (.*) mainDomain/$1    [QSA,L]

без субдомена htaccess

RewriteEngine on
    RewriteRule    ^$    public/    [QSA,L]
    RewriteRule    (.*)  public/$1    [QSA,L]

приложение htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?hedef=$1 [PT,L]

Я добавил поддомен cpanelden, но когда я запускаю поддомен, возникает бесконечная петля, как я могу это исправить?

пример ссылки на субдомен: http://ucgen.metehanboy.com/example/example другая ссылка: http://metehanboy.com/authentication/index

папка mainDomain включает приложение mvc php
Папка subsDomain содержит скрипты тестового приложения

Журнал ошибок Apache

[Wed May 02 14:16:26.044185 2018] [core:alert] [pid 3117] [client 95.70.153.106:59513] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLog', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:16:26.043954 2018] [core:alert] [pid 3117] [client 95.70.153.106:59513] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLog', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:42.256845 2018] [core:alert] [pid 2690] [client 95.70.153.106:59497] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:42.256734 2018] [core:alert] [pid 2690] [client 95.70.153.106:59497] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:34.964648 2018] [core:alert] [pid 2641] [client 95.70.153.106:59496] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:34.964434 2018] [core:alert] [pid 2641] [client 95.70.153.106:59496] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:21.351847 2018] [core:alert] [pid 2696] [client 95.70.153.106:59491] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:15:21.351768 2018] [core:alert] [pid 2696] [client 95.70.153.106:59491] /home/metehanboy/public_html/.htaccess: Invalid command 'RewriteLogLevel', perhaps misspelled or defined by a module not included in the server configuration
[Wed May 02 14:13:47.582923 2018] [core:error] [pid 3117] [client 95.70.153.106:59459] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/
[Wed May 02 14:13:47.582877 2018] [core:error] [pid 3117] [client 95.70.153.106:59459] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/
[Wed May 02 14:13:46.839964 2018] [core:error] [pid 3118] [client 95.70.153.106:59457] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/
[Wed May 02 14:13:46.839899 2018] [core:error] [pid 3118] [client 95.70.153.106:59457] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/
[Wed May 02 14:13:39.737762 2018] [core:error] [pid 2696] [client 95.70.153.106:59446] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/
[Wed May 02 14:13:39.737686 2018] [core:error] [pid 2696] [client 95.70.153.106:59446] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://ucgen.metehanboy.com/

1 Ответ

0 голосов
/ 11 мая 2018

В cPanel вы можете добавить субдомены рядом в свой основной домен вместо подкаталога. Зачем вам эта слишком сложная структура? В чем выгода? Используйте что-то вроде этого и избавьте себя от головной боли:

public_html/
 |____.htaccess (application htaccess)
 |____index.php
public_html_ucgen/
 |____.htaccess (subdomain htaccess)
 |____index.php
...