doutangliang7769 2014-05-14 12:45
浏览 44
已采纳

Zend Framework 1.12和Wordpress重定向错误

I'm having some problems using zend framework 1.12 and wordpress at the same time..

I know the problem needs to be in the htaccess because zend framework and wordpress are working.

The problem:

if surf to localhost/blog it redirects me to the url localhost/public_html/blog. When that happens wordpress opens and says it can't find anything..

But if i open it with localhost/blog/hello-world (where hello-world stand for a post) it works like a charm.

How can i make sure that if i'm surfing to localhost/blog the index page of wordpress blog will show up and that i will not be redirected to localhost/public_html/blog -> "not found" page.

my htaccess in public_html:

SetEnv APPLICATION_ENV development

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^blog - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

and my htaccess in /public_html/blog/

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>

# END WordPress

Thanks for reading and i hope someone can help me with this!

Greetings,

Cees

  • 写回答

2条回答 默认 最新

  • dongxu4023 2014-06-17 10:50
    关注

    I found the solution by myself so for the persons who are interested:

    I placed the blog in /public_html/wordpress But i put my links to: /blog

    my htaccess in public_html:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]
    

    and my htaccess in /public_html/wordpress/

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>
    
    # END WordPress
    

    I also changed my index.php in /public_html/index.php because i'm skipping the Zend bootstrap when /blog is called.

    <?php
    
    $aExplodedUri = explode('/', $_SERVER['REQUEST_URI']);
    
    
    if($aExplodedUri[1] == 'blog')
    {
    /**
     * Front to the WordPress application. This file doesn't do anything, but loads
     * wp-blog-header.php which does and tells WordPress to load the theme.
     *
     * @package WordPress
     */
    
    /**
     * Tells WordPress to load the WordPress theme and output it.
     *
     * @var bool
     */
    define('WP_USE_THEMES', true);
    
    /** Loads the WordPress Environment and Template */
    require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );
    
    }
    else
    {
    // Define path to application directory
    defined('APPLICATION_PATH')
        || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
    
    // Define application environment
    defined('APPLICATION_ENV')
        || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
    
    // Ensure library/ is on include_path
    set_include_path(implode(PATH_SEPARATOR, array(
        realpath(APPLICATION_PATH . '/../library'),
        get_include_path(),
    )));
    
    /** Zend_Application */
    require_once 'Zend/Application.php';
    
    // Create application, bootstrap, and run
    $application = new Zend_Application(
        APPLICATION_ENV,
        APPLICATION_PATH . '/configs/application.ini'
    );
    $application->bootstrap()
                ->run();    
    }
    

    You also need to change wp-config file and add the follow lines:

    define('WP_HOME','/blog');
    define('WP_SITEURL','http://www.yoururl.nl/wordpress');
    

    Good luck!

    Greetz,

    Cees

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题