Setup WordPress as a sub folder in Magento 2 directory - wordpress

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.

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.

For case if using Apache.
install Magento
install Wordpress to subfolder blog
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]
In folder pub create symbol link like
ln -s /var/html/blog /var/html/pub/blog

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]

Related

Magento & Wordpress Pretty Permalinks Issue

I have Magento installed on the root of my server.
I have Wordpress 4.0.1 installed on a sub-folder /blog
With permalinks set to default e.g. ?p=123 posts load correctly
With permalinks set to post name e.g. /blog/%postname%/ I get the 404 error from the Magento store
I've attempted to introduce an .htaccess file into the /blog folder with some settings in it, however as yet, I'm unable to set pretty permalinks and get the relevant post page to appear.
Any suggestions on what needs to be in the .htaccess file or howelse to resolve this issue?
Make sure you have following code in .htaccess which is in folder /Blog :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Wordpress inside Cakephp

I have installed Wordpress inside Cakephp's /app/webroot/blog/ folder and changed the wordpress permalink settings to Month and name (eg. http://abc.com/blog/2013/02/sample-post/).
Now when i am viewing a post i am getting Missing Controller(Error: BlogController could not be found).
I want to change the cakephp routes so that anything with /blog/* will point to webroot blog folder.
Can anybody help me on this?
When we change the permalink settings of Wordpress, it generates a .htaccess file, if there is required permission else we have to create it.
In the above case there was no .htaccess file inside /blog/ folder. I created it with the following mod_rewrite rules as provided by Wordpress while changing permalink settings.
<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>
After this every thing works fine.
There is no need to put the blog folder in webroot folder. You can access your folder by making slight changes in your .htaccess file. Just put your wordpress folder on root of cakephp with app folder and change .htaccess as given below.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (blog/.*) $1 [L] # adjust the regex to what you want.
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
I tried both the above codes but none work for me.. then i found something by my own and it worked..So here it is ,, hope this will help some.
First Add the WordPress folder inside the webroot folder as blog. Inside blog paste the WordPress directories and files.. install the WordPress.. Now you will see in the WordPress admin general settings WordPress Address as http://cakephp/blog/app/webroot/blog, Change it to http://cakephp/blog. Save it ..
Now look for the .htaccess file in WordPress install root folder change RewriteBase and RewriteRule (last one ) to RewriteBase /blog/ and RewriteRule . /blog/index.php [L]
<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>

Linking outside Wordpress page on localserver

I've updated my website to a Wordpress site.
But now i have a problem with my prestashop, that i still need to be running on the server/webhost.
On my old page i had the prestashop installation called 'shop' inside my old site folder - so the link would be mysite.com/shop = worked fine.
I have nice permalinks working on my site, taking up all directions outsite WP sites as 'No result WP page' - And im stocked here..
I dont know where to put my prestashop folder or how to link to it from Wordpress.
Have you set up the permailinks in Wordpress so your .htaccess looks like the following?;
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
The line RewriteCond %{REQUEST_FILENAME} !-d is telling the server not to include rewrites for directories which are in the root of the install, so anything within your shop directory shouldn't be processed through index.php.

Setting up a another website on a wordpress folder

I am setting up a website inside a wordpress installation folder.
So it's like:
http://mysite.com/newsite/
Primarily, http://mysite.com is a wordpress installation, now I want to set up another site*(not a wordpress website)* on that directory which is newsite,
So basically it looks like this mysite/newsite/
When I go to that link, it changes the URL and leads me to a page of mysite page. I think maybe because of the .htaccess of the wordpress installation.
How can I access on my newly setup website without being redirecting me to http://mysite.com page?
PS:
Wordpress .htaccess configuration:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Your help will be appreciated!

How to install another cms in a sub-directory of Wordpress

I am trying to install shopping cart cms "x-cart" in a sub-directory "/store/" on my Wordpress site.
I have permalinks enabled and mod rewrite in htaccess... So when I try to access anything within "/store/" folder i am getting wordpress 404 :(
How do I exclude "/store/" folder in htaccess?
Here is my current one:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thanks in advance!
If you have a folder called "store" you don't need to do anything. This line:
RewriteCond %{REQUEST_FILENAME} !-d
Is saying that "If the request is from a real directory (-d) ignore this index.php stuff and go with it". So, just create /store and put a "index.html" to see if it isn't an issue with x-cart instead of wp
If you are creating multi WP website, you can consider using WP multisites feature which can be found herecodex.
You might find it easier to either install x-cart on a sub-domain (store.yoursite.com), or just put it in a folder at the same level as wordpress yoursite.com/store.

Resources