Laravel公用文件夹中的WordPress返回404未找到

时间:2016-05-05 15:16:35

标签: .htaccess laravel laravel-5 laravel-routing

我在/dev.domain.com/中安装了一个laravel,RootDocument设置为/dev.domain.com/public

laravel没有任何问题,然后我在laravel的公共文件夹下名为“blog”的新创建的目录中安装WordPress

Wordpress路径:/dev.domain.com/public/blog

在localhost上,我可以照常访问/博客和设置wordpress,但问题是我通过使用git克隆来部署到实时服务器。 laravel路径工作正常,但当我尝试访问公共文件夹中的/ blog目录时,它返回 404 Not found

以下是Laravel

/dev.domain.com/public/.htacess

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

    RewriteEngine On

    # Redirect non ssl to ssl
    # and don't redirect subdomain
    RewriteCond %{HTTP_HOST} ^dev\.domain\.com [NC]
    RewriteRule ^(.*) - [L]

    RewriteCond %{HTTP_HOST} ^domain\.com [NC]
    RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]

    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,NE]

    # 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]
</IfModule>

和Wordpress

/dev.domain.com/public/blog/.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/

# Disable WordPress front-end
RewriteCond %{REQUEST_URI} !/wp-admin
RewriteCond %{REQUEST_URI} !/wp-includes
RewriteCond %{REQUEST_URI} !/wp-login\.php$
RewriteCond %{REQUEST_URI} !/wp-content
RewriteRule (.*) https://www.domain.com/ [R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

我试图添加这个,但没有机会使其有效

RewriteCond %{REQUEST_URI} !^/blog

上方

RewriteRule (.*) https://www.domain.com/ [R=301,L]

1 个答案:

答案 0 :(得分:1)

试试this recipe,它对我有用。

添加到Laravel .htaccess

RewriteCond %{REQUEST_URI} !^/blog/ #

在Wordpress .htaccess中更改这些行:

RewriteBase /blog/
RewriteRule . /blog/index.php [L]