【发布时间】:2013-11-16 02:19:12
【问题描述】:
我尝试在我的系统中集成 codeigniter 和 wordpress,它确实做到了。通过将 wordpress 放在我的 codeigniter 根目录中似乎可以正常工作,但已在 config、index 和 route.php 中进行了调整。我现在可以在我的 codeigniter 视图文件中使用 wp 函数,但是,出现了问题。每当我访问控制器中的其他函数时,它都会重定向到控制器的索引函数。这有什么问题? wp和ci url之间是否存在冲突或者可能有其他原因?如果有,我该如何解决这个问题?这是我的代码。感谢您的帮助。
配置.php
从:$config['index_page'] = 'index.php'; 到 $config['index_page'] = '';
routes.php
默认路由工作正常
来自:$route['default_controller'] = "welcome";
$route['404_override'] = '';
以下任何选项都会导致上述问题
到:3 个路由选项
选项 1:
# Option 1 - Use this section for a normal CI site
# with WP in its own folder
$route['default_controller'] = "ci_pages";
$route['(:any)'] = "wp_pages/$1";
$route['(:any)'] = "ci_pages/$1";
$route['404_override'] = '';
选项 2:
# Option 2 - Use this section for a blended CI/WP site
# with selected WP pages routed to eppear in the web root
# Any WP route outside the WP folder must be set up as a CI route.
$route['default_controller'] = "ci_pages";
$route['(:any)'] = "ci_pages/$1";
$route['sample-page'] = "wp_pages/$1";
$route['404_override'] = '';
选项 3:
# Option 3 - Use this section for a CI site where WP is only
# for content management and does not display its own pages
# through CI routing.
$route['default_controller'] = "ci_pages";
$route['(:any)'] = "ci_pages/$1";
$route['404_override'] = '';
控制器:ci_pages.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class CI_Pages extends CI_Controller
{
public function index()
{
$this->load->view('home');
}
public function test()
{
$this->load->view('test');
}
}
?>
【问题讨论】:
标签: php wordpress codeigniter