cuber's avatar

Install Wordpress in domain.com/blog/

I have Laravel running on mydomain.com and i would like to migrate my existing Wordpress blog under mydomain.com/blog/ so as not to have any broken links.

Obviously, anything after mydomain.com gets diverted into Laravel. What are the ways to solve this?

0 likes
11 replies
toniperic's avatar

I don't think you can.

Wordpress would need to be uploaded to the public directory in this case, and configured as per normal - but it's going to take over requests and do its job. You'd probably have to create a Wordpress plugin so that missed requests, or requests for certain domains get forwarded elsewhere (to Laravel, which can then do its job).

It may be possible... but you're going to have a hell of a hard time.

henrique's avatar

It is possible, but the exact process depends on a lot of things.

Are you using nginx or apache? Do you have ssh access?

Since the webroot is laravel's public folder, you either create the blog folder inside it or create it outside and create a symlink (if you have ssh access).

Then you edit your .htaccess or nginx config to handle access to /blog correctly (htaccess would ignore it and let the htaccess inside /blog handle it, nginx would ignore it and have a scope handling it), if you use apache and beautiful urls in wp, don't forget to update the rewritebase in wp's .htaccess.

The last step is to update the URL in the database, this might help: https://github.com/interconnectit/Search-Replace-DB Just be careful as it edits a field that is used by rss clients, so they know what is new and what is not.

1 like
citricsquid's avatar

You won't suffer from broken links if you set up 301 redirects. Hacking your way around Wordpress and Laravel to make this work is a waste of your time and will cause far more problems than it solves, migrating your blog to blog.example.com with 301 redirects on /blog -> blog.example.com will be very easy and very maintainable.

1 like
cuber's avatar

I would rather have the blog under domain/blog for seo purposes, @henrique yes im on a DigitalOcean server running nginx

What is the nginx configuration for such a change? so that Laravel will not take over when user goes to domain.com/blog/

alfonsan's avatar

Main problem with that approach is that you will suffer from duplicate user database.

Users in your main app, with already registered accounts, usernames, profiles, avatars, history, etc.. expect to use the same account, same credentials, same history, for the app and the blog.

This is a technical place, we all understand what disqus is, but on the average app you shouldn't take that for granted. You will generate unnecesary confusion.

Building a bridge between your app database, mailers, auth, and other modules with Wordpress would probably result in a lot more time than building your own blog using Laravel.

henrique's avatar

@cuber sorry, I don't know much about nginx.

But from what I know, the "location" directive that comes before, takes precedence, so you would first put the "location /blog" with wordpress config and then I think you can just leave the rest as is.

bashy's avatar

Just add another rule in Nginx config so it doesn't route via the Laravel /index.php

location /blog {
      index index.php;
      root /blog;
}

Untested of course, but you get the idea :)

2 likes
henrique's avatar

@cuber I just noticed you said "for SEO purposes", if you mean the subdomain vs subfolder thing, you might want to check this video: http://www.youtube.com/watch?v=_MswMYk05tk (notice it's from Google).

3 likes

Please or to participate in this conversation.