Бэкэнд-структура: Laravel v10.48.12 (PHP V8.1.29)
ОС Windows Server
Test Test Api Test Test Test Live Server src = "https://i.sstatic.net/yk7dvxp0.png"/>
apache httpd-vhost.conf с несколькими субдоменными проектами
Код: Выделить всё
DocumentRoot "C:/xampp/htdocs/exampleapi/public"
ServerName exampleapi.com
ServerAlias www.exampleapi.com
ErrorLog "logs/exampleapi.com-error.log"
CustomLog "logs/exampleapi.com-access.log" combined
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
RewriteCond %{QUERY_STRING} ^%ad [NC]
RewriteRule .? – [F,L]
#RewriteRule .* - [F]
DocumentRoot "C:/xampp/htdocs/exampleapi/public"
ServerName exampleapi.com
ServerAlias www.exampleapi.com
ErrorLog "logs/exampleapi.com-error.log"
CustomLog "logs/exampleapi.com-access.log" combined
SSLEngine on
SSLCertificateFile "crt/exampleapi.com/star.crt"
SSLCertificateKeyFile "crt/exampleapi.com/wildcard.key"
RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}
RequestHeader set "X-Forwarded-SSL" expr=%{HTTPS}
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
RewriteCond %{QUERY_STRING} ^%ad [NC]
RewriteRule .? – [F,L]
#RewriteRule .* - [F]
< /code>
.htaccess of c: \ xampp \ htdocs < /p>
RewriteEngine On
RewriteBase /
RewriteCond $1 !^(index\.html|assets|robots\.txt|favicon\.png)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.html [L]
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R]
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
# RewriteRule .* - [F]
RewriteCond %{QUERY_STRING} ^%ad [NC]
RewriteRule .? – [F,L]
Код: Выделить всё
127.0.0.1 example.com
127.0.0.1 adminexample.com
127.0.0.1 apiexample.com
< /code>
api.php code < /p>
Route::get('testapi', function () {
return response()->json([
'message' => "Api is working.",
], 201);
});
Подробнее здесь: https://stackoverflow.com/questions/796 ... ion-server