我让它发挥作用 . 它总是返回404错误 . WordPress安装在 /public_html
内,我需要在 /public_html/my-laravel-app
上安装Laravel . 这是我的 .htaccess
文件的外观:
/public_html/.htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# protect wpconfig.php
<files wp-config.php>
order allow,deny
deny from all
</files>
# protect the htaccess file
<files .htaccess>
order allow,deny
deny from all
</files>
# disable the server signature
ServerSignature Off
/public_html/my-laravel-app/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my-laravel-app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my-laravel-app/public/index.php [L]
</IfModule>
/public_html/my-laravel-app/public/.htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
/public_html/my-laravel-app/public/index.php (some part of index.php)
require __DIR__.'/../bootstrap/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
2 回答
我忘了更新这个问题,但我已经解决了这个问题 . It's not actually about WordPress' .htaccess, I get rid of my custom .htaccess settings . 我做的是,在
public_html/laravel-app
上创建一个新文件夹,然后在我的laravel-app
里面,这是我克隆回购的地方,所以它变成了,public_html/laravel-app/my-app
然后,我复制了my-app/public
目录中的文件(文件夹除外)并将其移动到laravel-app/
. 然后我通过运行为my-app/public
内的目录创建了一个符号链接然后,最后,我修改了第22行和第36行的
public_html/laravel-app/index.php
,然后它完成了 .
Laravel不适用于开箱即用的子文件夹 . 您需要调整一些文件才能使其正常工作 . 看看laravel-news.com上的以下文章
我的建议是重新考虑你的方法,看看是否有不同的方法来实现你的目标,不需要子文件夹 .
编辑:
我想在文章中包含更多步骤,以防将来删除,但步骤太多了 .