首页 > 解决方案 > Laravel 与 WordPress 在共享主机上

问题描述

我在共享主机上有一个 wordpress 网站,我想为它创建一个 laravel 管理面板。
我根据这个页面工作过,我的文件结构是这样的:

domains/
│
└── mydomain.com/
    │
    ├── laravel/
    │    │
    │    └── laravel files
    │
    └── public_html/
          │
          ├── wordpress files
          │
          └── appadmin/
              │
              ├── css/
              │
              ├── fonts/
              │
              ├── js/
              .
              .
              .
              │
              ├── .htaccess
              │
              └── index.php

并更改appadmin/index.php为访问laravel文件。
索引.php:

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

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


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

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

我的 laravel 管理员登录路径是/login这意味着 laravel 管理员登录 url 是mydomain.com/appadmin/login并且它工作正常。

但!当我输入用户名和密码(不管是错还是正确)并点击提交按钮时,页面将重定向到mydomain.com/wp-login.php

编辑:这些是 laravel 和 wp.htaccess文件

wp htaccess:

# BEGIN iThemes Security - این خط را تغییر یا حذف نکنید
# iThemes Security Config Details: 2
    # مسدودسازی میزبان - امنیت > تنظیمات > کاربران مسدود شده
    SetEnvIF REMOTE_ADDR "^5\.45\.69\.4$" DenyAccess
    SetEnvIF X-FORWARDED-FOR "^5\.45\.69\.4$" DenyAccess
    SetEnvIF X-CLUSTER-CLIENT-IP "^5\.45\.69\.4$" DenyAccess

    SetEnvIF REMOTE_ADDR "^192\.99\.15\.141$" DenyAccess
    SetEnvIF X-FORWARDED-FOR "^192\.99\.15\.141$" DenyAccess
    SetEnvIF X-CLUSTER-CLIENT-IP "^192\.99\.15\.141$" DenyAccess

    SetEnvIF REMOTE_ADDR "^149\.56\.241\.211$" DenyAccess
    SetEnvIF X-FORWARDED-FOR "^149\.56\.241\.211$" DenyAccess
    SetEnvIF X-CLUSTER-CLIENT-IP "^149\.56\.241\.211$" DenyAccess

    SetEnvIF REMOTE_ADDR "^31\.222\.187\.197$" DenyAccess
    SetEnvIF X-FORWARDED-FOR "^31\.222\.187\.197$" DenyAccess
    SetEnvIF X-CLUSTER-CLIENT-IP "^31\.222\.187\.197$" DenyAccess

    <IfModule mod_litespeed.c>
        Order allow,deny
        Allow from all
        Deny from env=DenyAccess
        Deny from 5.45.69.4
        Deny from 192.99.15.141
        Deny from 149.56.241.211
        Deny from 31.222.187.197
    </IfModule>
# END iThemes Security - این خط را تغییر یا حذف نکنید

# This file was updated by Duplicator on 2018-12-05 08:05:28. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(appadmin|user)($|/) - [L] #To Shailor's suggestion
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

拉拉维尔htaccess

<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]

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

标签: phpwordpresslaravelshared-hostinglaravel-6

解决方案


重新检查 laravel 和 wordpress .htaccess 文件。要排除 appadmin,您应该在任何其他 RewriteRule 之前将此行添加到 wp 的 .htaccess 中。如果这不能解决您的问题,请使用 .htaccess 文件更新您的问题,我也会更新我的答案

RewriteRule ^(appadmin|user)($|/) - [L]

推荐阅读