/ .htaccess

Running WordPress Blog From CakePHP

If you are CakePHP developer, you probably know that files and folders located at app/webroot directory, are visible from URLs directly. For example, if you keep example.pdf file in your webroot directory, you can access it from http://yoursite.com/example.pdf.

This logic was earlier used to add a WordPress blog to CakePHP. All you had to do is, copy your WordPress folder (renamed to ‘blog’, most of the time) in your webroot directory, so that blog can run from http://yoursite.com/blog. You might need edit .htaccess files to suit your server settings.

I tried the above method and tried various .htaccess settings, but nothing worked with server settings that I use. The issue that I remember where I stopped was that I had to make sure that there’s always a forward slash afterword blog. So /blog wasn’t working as expected.

Finally, the solution that worked for me is to not keep the blog directory in the webroot folder. Instead, I moved it to the same folder where my ‘app’ folder stayed. Additionally, I had to write two lines to tell CakePHP that not to consider blog/ at all.

Rakesh Tembhurne

Rakesh Tembhurne

Rakesh is a father, software engineer, author and mentor having more than 8+ years of experience in web apps development.

Read More