在root上安装CodeIgniter,在子目录中安装WordPress

时间:2010-03-24 18:38:35

标签: php wordpress codeigniter

我想创建一个网站,主页将从CodeIgniter提供。我将在/ blog /子目录中使用Wordpress来托管博客。而已!我什么都不想要。只是为了确保:

example.com/somepage/调用CI控制器,其中example.com/blog/some-post/由Wordpress处理。

我不需要CI和WP之间的任何集成或交互。

是否可以这样安装?如果没有,任何解决方法,以便我可以实现目标?

谢谢和问候, Masnun

3 个答案:

答案 0 :(得分:8)

我怀疑你可以使用网站根目录中的.htaccess文件来解决这个问题。如果blog是安装WordPress的子目录的名称,并且您希望word.com/blog由WordPress处理,请尝试以查看它是否有帮助:

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|blog)
RewriteRule ^(.*)$ /index.php/$1 [L]

答案 1 :(得分:1)

它应该像您描述的那样工作,没有任何复杂的配置。只需在根目录中安装codeigniter,然后创建一个博客目录并将wordpress放在那里。

答案 2 :(得分:0)

+1 Rich的方法

另外,如果您使用的是.htaccess文件,就像CI文档中建议的文件一样,它应该通过将WP目录直接删除到web根目录来工作。

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]

由于RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d直接向网络服务器上的真实文件发出的任何调用都将由Apache直接提供,其他uris将由CI的路由机制来处理。

注意我们使用了最后一个RewriteCond指令来排除对某些文件的调用,包括我们的资产dir(包含images / css / js静态文件)和'corporate'dir,在这种情况下包含一个博客。

虽然这个例子不使用wordpress,但它有自己的url重写和路由系统。

总而言之,如果你想使用WP网址重写,你将使用特定的RewriteCond语句,如果没有它可以使用它。