views:

334

answers:

5

Hello,

I want to create a website where the main pages will be served from CodeIgniter. I will use Wordpress in the /blog/ sub-directory to host the blog. Thats it! I want nothing else. Just to make sure that:

example.com/somepage/ calls a CI controller where as example.com/blog/some-post/ is handled by Wordpress.

I don't need any kind of integration or interaction between CI and WP.

Is it possible to install in that way? If not, any workarounds so that I can achieve the objectives?

Thanks and Regards, Masnun

+1  A: 

It should work just as you described it without any complicated configuration. Just install codeigniter in your root directory and then create a blog directory and put wordpress in there.

jswat
A: 

It is possible to install CI as a framework within WP. Here's a step-by-step. All pages, including the WP blog posts, etc, would be handled as CI views. Hope this helps.

Lenwood
I need WP inside CI. I'll have a look. Thanks :)
maSnun
You may have already seen this, but a new thread just popped up within the CI forum that addresses this.http://codeigniter.com/forums/viewthread/151352/
Lenwood
+3  A: 

I suspect you could get this to work using an .htaccess file in the root directory of your site. If blog is the name of the subdirectory where WordPress is installed, and you want example.com/blog to be handled by WordPress, try this to see if it helps:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|blog)
RewriteRule ^(.*)$ /index.php/$1 [L]
Rich
Thanks. From the look of it, it should work. I'm gonna try this.
maSnun
That's the way we integrate CI with other apps/sites. This could be declined to work in both ways : CI app into wordpress dir, and wordpress inside CI app dir.
Benoit
A: 

+1 with Rich's method

Additionnaly, if you're using a .htaccess file like the one suggested on CI doc, it should work by dropping WP directory directly into web root dir.

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)


RewriteCond $1 !^(index\.php|robots\.txt|corporate|assets)
RewriteRule ^(.*)$ index.php/$1 [L]

Because of the RewriteCond %{REQUEST_FILENAME} !-f and RewriteCond %{REQUEST_FILENAME} !-d any call made directly to a real file on webserver would be served directly by Apache, other uris wil be handled by CI's routing mecanism.

Notice we used a last RewriteCond directive to exclude calls to certains files, including our assets dir (containing images/css/js static files) and 'corporate' dir which contains in this case a blog.

Although this example do not use wordpress, it has its own url-rewriting and routing system.

In a matter of conclusion, you'll have use a specific RewriteCond statement if you want to use WP url-rewriting, if not it could work without it.

Benoit