简体   繁体   English

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

[英]Installing CodeIgniter on root and WordPress in sub-directory

I want to create a website where the main pages will be served from CodeIgniter. 我想创建一个网站,主页将从CodeIgniter提供。 I will use Wordpress in the /blog/ sub-directory to host the blog. 我将在/ blog /子目录中使用Wordpress来托管博客。 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. example.com/somepage/调用CI控制器,其中example.com/blog/some-post/由Wordpress处理。

I don't need any kind of integration or interaction between CI and WP. 我不需要CI和WP之间的任何集成或交互。

Is it possible to install in that way? 是否可以这样安装? If not, any workarounds so that I can achieve the objectives? 如果没有,任何解决方法,以便我可以实现目标?

Thanks and Regards, Masnun 谢谢和问候,Masnun

I suspect you could get this to work using an .htaccess file in the root directory of your site. 我怀疑你可以使用站点根目录中的.htaccess文件来使用它。 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: 如果blog是安装WordPress的子目录的名称,并且您希望word.com/blog由WordPress处理,请尝试以查看它是否有帮助:

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

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. 只需在根目录中安装codeigniter,然后创建一个博客目录并将wordpress放在那里。

+1 with Rich's method 用Rich的方法+1

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. 另外,如果您使用的是.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]

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

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

Although this example do not use wordpress, it has its own url-rewriting and routing system. 虽然这个例子不使用wordpress,但它有自己的url重写和路由系统。

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. 最后,如果你想使用WP url-rewriting,你将使用特定的RewriteCond语句,如果没有它可以使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM