Zend Framework 1.12和Wordpress重定向错误

时间:2014-05-14 12:45:04

标签: php wordpress .htaccess zend-framework redirect

我在同时使用zend framework 1.12和wordpress时遇到了一些问题..

我知道问题需要在htaccess中,因为zend框架和wordpress正在工作。

问题:

如果浏览localhost/blog它会将我重定向到网址localhost/public_html/blog。当发生这种情况时,wordpress会打开并说它找不到任何东西......

但如果我用localhost/blog/hello-world打开它(其中hello-world代表帖子)就像魅力一样。

如何确保如果我正在浏览localhost/blog wordpress博客的索引页面,并且我将不会被重定向到localhost/public_html/blog - > "未找到"页。

我的htaccess在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]

和我的htaccess在/ 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

感谢阅读,我希望有人可以帮助我!

问候,

塞斯

2 个答案:

答案 0 :(得分:0)

从根 .htaccess

中删除此行
RewriteRule ^blog - [NC,L]

如果系统找到了文件夹/文件,它将被使用!

博客/ .htaccess 文件中删除此行:

RewriteRule . /blog/index.php [L]

答案 1 :(得分:0)

我自己找到了解决方案,以便感兴趣的人:

我将博客放在/ public_html / wordpress中 但我把我的链接:/ blog

我的htaccess在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]

和我的htaccess在/ 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

我还在/public_html/index.php中更改了我的index.php,因为我正在调用/ blog时跳过Zend引导程序。

<?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();    
}

您还需要更改wp-config文件并添加以下行:

define('WP_HOME','/blog');
define('WP_SITEURL','http://www.yoururl.nl/wordpress');
祝你好运!

格尔茨,

塞斯