从十月/ Laravel安装重定向

时间:2018-09-25 14:45:18

标签: wordpress laravel .htaccess octobercms

我有一个使用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(十月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]

谢谢,维特纳

2 个答案:

答案 0 :(得分:0)

如果您可以发布.htaccess文件的问题区域,将会有所帮助。无论如何,请尝试将此RewriteCond添加到RewriteRule重定向到index.php的上方:

RewriteCond %{REQUEST_URI} !^/blog(.*)$

答案 1 :(得分:0)

您尝试创建别名吗?

在您的octoberCMS apache conf(位于apache conf.d目录中)中,您可以添加以下行:

Alias /blog /path/to/www/blog