【发布时间】:2019-03-01 05:49:56
【问题描述】:
我有一个使用 October 构建的网站(基于 Laravel),并且 .htaccess 文件将所有请求都指向 index.php 页面,如预期的那样。我希望 www 根文件夹中有一个单独的目录指向一个博客,我将在其中安装一个 WordPress 实例。所以文件夹结构将如下所示:
www/
.htaccess
artisan
index.php
/blog <-- i want to install the WP blog here
/bootstrap
/config
/modules
/storage
/themes
/vendor
我尝试过重定向,但我对 .htaccess 不太擅长,并且不想因为出错而冒着网站停机的风险
有一堆 RewriteCond 语句使用 !阻止某些文件夹,然后使用标准 RewriteRule 过滤对 index.php 的请求
我想要在传入请求中检查 /blog 并绕过 index.php,将请求发送到我的 WP 安装所在的 /blog。
这是当前的 .htaccess(10 月 CMS 的默认设置)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
##
## You may need to uncomment the following line for some hosting environments,
## if you have installed to a subdirectory, enter the name here also.
##
# RewriteBase /
##
## Uncomment following lines to force HTTPS.
##
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
##
## Black listed folders
##
RewriteRule ^bootstrap/.* index.php [L,NC]
RewriteRule ^config/.* index.php [L,NC]
RewriteRule ^vendor/.* index.php [L,NC]
RewriteRule ^storage/cms/.* index.php [L,NC]
RewriteRule ^storage/logs/.* index.php [L,NC]
RewriteRule ^storage/framework/.* index.php [L,NC]
RewriteRule ^storage/temp/protected/.* index.php [L,NC]
RewriteRule ^storage/app/uploads/protected/.* index.php [L,NC]
##
## White listed folders
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} !/.well-known/*
RewriteCond %{REQUEST_FILENAME} !/storage/app/uploads/.*
RewriteCond %{REQUEST_FILENAME} !/storage/app/media/.*
RewriteCond %{REQUEST_FILENAME} !/storage/temp/public/.*
RewriteCond %{REQUEST_FILENAME} !/themes/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/plugins/.*/(assets|resources)/.*
RewriteCond %{REQUEST_FILENAME} !/modules/.*/(assets|resources)/.*
RewriteRule !^index.php index.php [L,NC]
##
## Block all PHP files, except index
##
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.php$
RewriteRule !^index.php index.php [L,NC]
##
## Standard routes
##
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
谢谢,维特纳
【问题讨论】:
-
您希望两个网站使用相同的域名吗?不适合使用 cookie 和会话变量
-
hmmm,没想到...在最后的分析中,我可能会使用 blog.thedomain.com 但这实际上是临时的,但感谢您的警告。
标签: wordpress laravel .htaccess octobercms