Combine WordPress and Laravel

Often there is such a situation when it is necessary to combine CMS WordPress and Laravel site. There are various situations, but I will list some that our team personally encountered:

  1. For an old WordPress site, you need to develop a separate personal account on Laravel
  2. For a new Laravel site, you need to implement a WordPress blog in order to “not bother”

There can be many solutions to such situations. The developer always has the question of what to choose and how to implement.

Personal account on Laravel for WordPress site

Let’s consider the first case, because I’m sure it occurs more often.

First, you need to remember that if a WordPress site is old and authoritative enough, then the site owner is unlikely to want to lose positions in search engines. Therefore, in order to keep the old URLs and not actually touch the old site, the logical solution would be to move Laravel to a separate subdomain, for example, to cabinet.site.com.

Thus, the old site will retain its traffic and functionality, and there will be a beautiful URL for the office. If you need to work with the database of the WordPress site on the Laravel site, then you can create a second connection to the database according to the instructions.

If it is necessary to embed laravel in the site URL, for example site.com/cabinet/, then it is enough to place Laravel on the same server and correct the Apache config. In this case, all HTTP requests from the site.com/cabinet/ address should be sent in the config to the public folder in the Laravel project.

In my opinion, the right decision would be to place a new personal account on a subdomain. It’s easier to configure and the main site won’t require any changes.

WordPress blog for a site on Laravel

If you need a WordPress blog for a Laravel site, then the easiest solution is to place the blog in a separate folder on the server. The folder should be next to the Laravel project folder. In this case, you should create a symlink from the public Laravel folder of the project to the blog folder. In this case, all requests to site.com/blog/ will be redirected to the WordPress blog folder, and everything will work correctly.

Also, an effective solution would be to host a blog on a separate subdomain. To do this, it is enough to register A records in the DNS servers of the domain to the desired hosting or server where the WordPress blog will be located.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top