Laravel public 文件夹中的 WordPress returns 404 未找到
WordPress in Laravel public folder returns 404 not found
我在 /dev.domain.com/ 中安装了 laravel 并且 RootDocument 设置为 /dev.domain.com/public
laravel 没有任何问题,然后我将 WordPress 安装在 laravel 的 public 文件夹
下新创建的名为 "blog" 的目录中
WordPress 路径:/dev.domain.com/public/blog
在本地主机上,我可以像往常一样访问 /blog 和设置 wordpress,但是问题是我通过克隆 git 部署到实时服务器。 laravel 路径工作正常但是当我尝试访问 public 文件夹中的 /blog 目录时 returns 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/ [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 ^(.*)/$ / [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]
试试 this recipe,对我有用。
添加到 Laravel .htaccess
:
RewriteCond %{REQUEST_URI} !^/blog/ #
并在 Wordpress 中更改这些行 .htaccess
:
RewriteBase /blog/
RewriteRule . /blog/index.php [L]
我在 /dev.domain.com/ 中安装了 laravel 并且 RootDocument 设置为 /dev.domain.com/public
laravel 没有任何问题,然后我将 WordPress 安装在 laravel 的 public 文件夹
下新创建的名为 "blog" 的目录中WordPress 路径:/dev.domain.com/public/blog
在本地主机上,我可以像往常一样访问 /blog 和设置 wordpress,但是问题是我通过克隆 git 部署到实时服务器。 laravel 路径工作正常但是当我尝试访问 public 文件夹中的 /blog 目录时 returns 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/ [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 ^(.*)/$ / [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]
试试 this recipe,对我有用。
添加到 Laravel .htaccess
:
RewriteCond %{REQUEST_URI} !^/blog/ #
并在 Wordpress 中更改这些行 .htaccess
:
RewriteBase /blog/
RewriteRule . /blog/index.php [L]