Everyone is pretty familiar with the concept of building an entire website using the WordPress CMS. But what if you already have a fully developed website that you want to add CMS functionality to without rewriting and restructuring the entire thing? WordPress is a powerful tool that can allow you to do just that. But first, you will need some basic understanding of how WordPress works and where to draw the line between leveraging WP and frankensteining it.
Right out of the box, WP can be installed in a subdirectory of your website to control that part of your website. The most common use of this is adding a blog to your website. (mysite.com/blog) . But WordPress can do so much more. Let's look at the WP htaccess code and I'll explain.
You can see that WP rewrites ANY request that does not match an existing file or directory to the index.php file. This gives WP a chance to match the requested URL to any of it's internal permalinks using its own routing engine. What does this mean? It means that any request that doesn't match one of your existing file or folder names will automatically be picked up by WordPress and return the relevant document. But what if I already have an index.php file in my existing application? Not to worry, just rename WP's index.php to something else, ie: wordpress.php and update the corresponding line in the htaccess rules! To make this work, simply install WordPress into a subfolder of you site as you normally would BUT during setup, change the site root URL from mysite.com/blog to simply mysite.com. Once that's done, you only need to copy the index.php file from your subdirectory to your root directly (renaming if needed) and edit a single line of code, so it knows where to find the WordPress installation. Let's say you named your folder 'wordpress', then you would want your index.php and .htaccess files to look like below.
But wait, there's more! Doing the above allows you to dynamically create and modify any page for your website that doesn't already exist but limits you to a single environment. What can you do if you have different users that should be able to control different portions of your website's dynamic content? Why you upgrade to WordPress MultiSite of course! MultiSite allows you to define additional subsites ontop of your existing WP installation. So, you can have one sub-site for a blog, one sub-site for promotions, and one to control everything else.
Why would you ever want to do this anyway? Well that's easy to answer. A lot of the time when you want to utilize WordPress' CMS features, but you have some non-trivial application code, you end up having to shoehorn your logic into the WordPress framework to make it work. This solution allow you to keep them completely separate and give you the best of both worlds without forcing WP into something it's not.