[英]Setup WordPress as a sub folder in Magento 2 directory
I have Magento 2 and want to setup WordPress in a subfolder, so it will be accessed via magento2.url/blog我有 Magento 2 并想在子文件夹中设置 WordPress,因此将通过 magento2.url/blog 访问它
I know about Fishpig but for my situation, it will not work because WordPress site has a lot of custom post types which is not supported by FishPig integration by default.我知道 Fishpig,但就我的情况而言,它不起作用,因为 WordPress 站点有很多自定义帖子类型,默认情况下,FishPig 集成不支持这些类型。
Right now if I tried to access magento2.url/blog it shows a 404 error Magento 2 page.现在,如果我尝试访问 magento2.url/blog,它会显示 404 错误 Magento 2 页面。
I modified .htaccess in WordPress subfolder to this:我将 WordPress 子文件夹中的 .htaccess 修改为:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
But it not helps and home page for WordPress still shows a 404 Magento 2 page.但这无济于事,WordPress 的主页仍然显示 404 Magento 2 页面。 I think I need to modify .htaccess in Magento 2 but not really sure how.
我想我需要在 Magento 2 中修改 .htaccess 但不确定如何修改。
The .htaccess is irrelevant when integrating WordPress into Magento.将 WordPress 集成到 Magento 时,.htaccess 无关紧要。 This file only applies when accessing WordPress directly (ie. for a WordPress Admin request).
此文件仅适用于直接访问 WordPress(即 WordPress 管理员请求)。
Here are basic installation instructions:以下是基本安装说明:
This is all you need to do to integrate WordPress at /blog.这就是将 WordPress 集成到 /blog 所需要做的全部工作。
The .htaccess file has no impact here, however you should change /blog/ to /wp/ in the .htaccess for WordPress. .htaccess 文件在这里没有影响,但是您应该将 WordPress 的 .htaccess 中的 /blog/ 更改为 /wp/。 The correct value is:
正确的值是:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
For a full installation guide, see this link .有关完整的安装指南,请参阅此链接。
As answered on https://magento.stackexchange.com/a/53757 you should install WordPress outside the Magento directory.正如在https://magento.stackexchange.com/a/53757 上回答的那样,您应该在 Magento 目录之外安装 WordPress。
Despite of that, in your case you must edit Magento .htaccess
because WP can't be accessed wich explains the Magento 404 error.尽管如此,在您的情况下,您必须编辑 Magento
.htaccess
因为无法访问 WP,这解释了 Magento 404 错误。
RewriteRule ^/blog/(.*) /blog/$1 [QSA]
For case if using Apache.对于使用 Apache 的情况。
add to .htaccess & pud/.htaccess following code添加到 .htaccess & pud/.htaccess 以下代码
RewriteEngine On RewriteBase /blog/ RewriteRule ^index\\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /blog/index.php [L]
In folder pub create symbol link like在文件夹 pub 创建符号链接,如
ln -s /var/html/blog /var/html/pub/blog ln -s /var/html/blog /var/html/pub/blog
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.