Created
February 15, 2016 17:09
-
-
Save seansch/cd227732d1b4415bd0dc to your computer and use it in GitHub Desktop.
Simple Laravel / Wordpress Integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public/index.php | |
// Wordpress / Laravel Integration | |
// Wordpress lives in public/wp/ | |
if ( file_exists(__DIR__.'/wp/index.php') ) { | |
// Retrieve the current URL | |
$segments = explode('/', trim($_SERVER['REQUEST_URI'], '/')); | |
// Get first URL segment, strip any GET params | |
$segment = strtok($segments[0], '?'); | |
// Reserved app URLS, these will all be routed to Laravel, | |
// All others will be passed to Wordpress. | |
$urls = ['reseverd-url1','reseverd-url2','reseverd-url3','auth', 'password', 'etc']; | |
if ( ! in_array($segment, $urls) ) { | |
// Load Wordpress | |
require_once __DIR__.'/wp/index.php'; | |
exit; | |
} | |
} | |
// End Wordpress integration | |
/** | |
* Laravel - A PHP Framework For Web Artisans | |
* | |
* @package Laravel | |
* @author Taylor Otwell <[email protected]> | |
*/ | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment