我有以下虚拟本地网站(通过两个不同的虚拟主机配置):
[vhost 1]
https://www.test-laravel.com
DocumentRoot "${INSTALL_DIR}/www/[WEBSITE-DIR]"
[vhost 2]
https://www.test-laravel-direct.com
DocumentRoot "${INSTALL_DIR}/www/[WEBSITE-DIR]/laravel/public"
您可以在此处通过GitHub
进行检查:
https://github.com/napolev/test-laravel.com
在其目录中,我删除了4个文件:
index.php
page_01.php
page_02.php
page_03.php
具有相同内容(只是表示当前文件):
<?
echo 'You are on: '.$_SERVER['PHP_SELF'];
?>
此外,我在其目录中安装了Laravel
:
$ laravel new api
在文件上:laravel\routes\api.php
我配置了以下路由:
Route::post('/echo-post', function (Request $request) {
return request()->all();
});
如果我将[vhost 2]
与Postman
一起使用,请使用以下POST
URL请求:
(在这种情况下,域指向子目录:/laravel/public
而不是根目录)
https://www.test-laravel-direct.com/api/echo-post?param1=value1¶m2=value2¶m3=value3
我得到了预期的答复:
{
"param1": "value1",
"param2": "value2",
"param3": "value3"
}
然后,我想通过以下[vhost 1]
URL请求将Postman
与POST
一起使用:
(在这种情况下,域指向的是根目录,而不是子目录:/laravel/public
)
https://www.test-laravel.com/api/echo-post?param1=value1¶m2=value2¶m3=value3
为此,我将根.htaccess
文件配置为:
RewriteEngine On
RewriteBase /laravel/
RewriteRule ^api/(.*)$ /api/$1 [L]
但是当使用Postman
运行请求时,我得到以下输出:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>500 Internal Server Error</title>
</head>
<body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
admin@example.com to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body>
</html>
在Apache
错误日志中,我得到以下信息:
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.
您对如何将[vhost 1]
与以下POST
URL请求一起使用有任何想法吗?
https://www.test-laravel.com/api/echo-post?param1=value1¶m2=value2¶m3=value3
谢谢!