gpt4 book ai didi

wordpress - 从位于别处的目录访问特定的 Laravel 5 路由

转载 作者:行者123 更新时间:2023-12-04 12:28:59 25 4
gpt4 key购买 nike

我安装了wordpress:

example.com

和 laravel /public dir(从 api.example.com 访问)
example.com/api

我如何访问 laravel 路由说 /play来自 example.com/play
目前我有这个 example.com/play/play显示正确的 Laravel 路线,但我需要它来提升水平。

设置
/home/public_html/play 中的 index.php
require __DIR__.'/../../laravel/bootstrap/autoload.php';
$app = require_once __DIR__.'/../../laravel/bootstrap/app.php';

这正确指向 /home/laravel例如

那么路由文件是
Route::group(['prefix' => 'play'], function () {    
Route::get('/', ['as'=>'/', 'uses'=>'Controller@play']);
});

我已添加 RewriteCond %{REQUEST_URI} !^/(play/.*)$根 .htaccess 所以 wordpress 不会接管。

最后这就是我遇到问题的地方:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /play/index.php [L]

</IfModule>

位于 /home/public_html/play
那么如何在/play 目录中显示 Laravel 路由呢?
这可以通过重写来实现吗?
我可以将参数传递给 laravel 以告诉它以 root 身份启动/play 吗?

最佳答案

当您想从单个域访问多个应用程序时,最好的实现是为每个应用程序启动不同的服务器。您可以设置从主应用程序到其他应用程序的代理。

您可以使用如下设置为您的 Laravel 应用程序启动 apache2 服务器

<VirtualHost 0.0.0.0:8080>
DocumentRoot "path-to-laravel-app"

<Directory "path-to-laravel-app">

Options Indexes FollowSymLinks Includes ExecCGI

AllowOverride All
Require all granted
Allow from all
</Directory>
</VirtualHost>

然后在你的 wordpress 应用程序中设置代理 .htaccess像这样的文件
ProxyPass "/play"  "http://locahost:8080/play"
ProxyPassReverse "/play" "http://locahost:8080/play"

关于wordpress - 从位于别处的目录访问特定的 Laravel 5 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40130852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com