skip to Main Content

I have Magento 2 and want to setup WordPress in a subfolder, so it will be accessed via 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.

Right now if I tried to access magento2.url/blog it shows a 404 error Magento 2 page.

I modified .htaccess in WordPress subfolder to this:

# 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. I think I need to modify .htaccess in Magento 2 but not really sure how.

3

Answers


  1. As answered on https://magento.stackexchange.com/a/53757 you should install WordPress outside the Magento directory.

    Despite of that, in your case you must edit Magento .htaccess because WP can’t be accessed wich explains the Magento 404 error.

    RewriteRule ^/blog/(.*) /blog/$1 [QSA]
    
    Login or Signup to reply.
  2. The .htaccess is irrelevant when integrating WordPress into Magento. This file only applies when accessing WordPress directly (ie. for a WordPress Admin request).

    Here are basic installation instructions:

    • Install WordPress in a sub-directory of Magento called wp.
    • If you use the pub directory to display Magento, either install WordPress at pub/wp or create a symlink at pub/wp to point to the actual wp folder.
    • Check the wp_options table for the home and siteurl values. The siteurl value should be the /wp URL and the home option should be your /blog URL

    This is all you need to do to integrate WordPress at /blog.

    The .htaccess file has no impact here, however you should change /blog/ to /wp/ in the .htaccess for WordPress. 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.

    Login or Signup to reply.
  3. For case if using Apache.

    1. install Magento
    2. install WordPress to subfolder blog
    3. add to .htaccess & pud/.htaccess following code

      RewriteEngine On
      RewriteBase /blog/
      RewriteRule ^index.php$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /blog/index.php [L]

    4. In folder pub create symbol link like

      ln -s /var/html/blog /var/html/pub/blog

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search