我在(html_public)文件夹中有wordpress项目,我的域运行项目很好,我想在wordpress中集成laravel8项目,以便两者在同一个域中运行

WordPress URLs:

  • 一百

  • 一百

Laravel URLs:

  • 一百

  • 一百

Wordpress && LaravelApp path in cpanel:

public_html/
wp-admin
wp-content/
wp-includes/
... other wordpress files ...
laravelApp/ <-- laravel application folder
|-> app/
|-> bootstrap/
|-> config/
|-> public/
|-> ... other laravel files and directories ...

Wordpress .haccess:

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Laravel .haccess in /public:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

wordpress index.php:

    <?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define( 'WP_USE_THEMES', true );

/** Loads the WordPress Environment and Template */
require __DIR__ . '/wp-blog-header.php';

Laravel index.php in App/public/index.php:

    <?php

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Check If The Application Is Under Maintenance
|--------------------------------------------------------------------------
|
| If the application is in maintenance / demo mode via the "down" command
| we will load this file so that any pre-rendered content can be shown
| instead of starting the framework, which could cause an exception.
|
*/

if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) {
    require $maintenance;
}

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| this application. We just need to utilize it! We'll simply require it
| into the script here so we don't need to manually load our classes.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request using
| the application's HTTP kernel. Then, we will send the response back
| to this client's browser, allowing them to enjoy our application.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

$kernel = $app->make(Kernel::class);

$response = $kernel->handle(
    $request = Request::capture()
)->send();

$kernel->terminate($request, $response);

有什么需要帮忙的吗?

推荐答案

在根目录中创建一个文件夹,并将laravel项目文件夹转储到该文件夹中,然后创建.htaccess位于laravel项目文件夹内,然后指向该文件夹.HTC访问laravel公共目录索引文件.你的项目会顺利进行.

Php相关问答推荐

无法添加ProxyClass__setInitialized()上的忽略

尽管包含目标日期,但日期范围比较仍有意外输出

为什么在我的PHP联系人脚本中开机自检后出现未定义变量错误?

无法使用php IMAP从Gmail获取收件箱

WHERE方法不能与有效查询Laravel一起使用

如何不重新查询模型A-&>;相关模型B-&>模型

在WP工具中页面加载时可短暂看到的JavaScript生成的字段

在PHP项目中安装OpenAI PHP SDK时出现问题

在 Woocommerce 邮箱订单中显示产品 GTIN

Laravel 在数据库上显示加密列

WooCommerce:如果购物车中已存在产品,则增加购物车商品数量

laravel Eloquent 模型的问题

PHP 中的curl -F request=@file.xml

计算数组中连续值的数量

Woocommerce注册中的自定义复选框验证错误提示问题

WooCommerce checkout 流程中基于所选选项添加自定义费用

我怎样才能在 .htaccess 中有 2 个参数?

在 WooCommerce 结帐后更新用户元字段

路由未定义的 laravel 导出

Laravel - 按 SQL 表列对来自其他类的数组进行排序