Welcome Guest, Not a member yet? Register   Sign In
redirect() problem
#1

[eluser]gevans[/eluser]
Hey guys,

I currently have a codeigniter installation, with wordpress running along side. It's running locally at present so I don't have a live example. The layout is fairly standard;

site/
site/index.php
site/.htaccess
site/application
site/system
site/system

.htaccess
Code:
RewriteEngine on

RewriteCond $1 !^(index\.php|resources|news|robots\.txt|sitemap\.xml)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?$1 [L,QSA]

I have a controller that doesn't allow direct access;

Code:
class Form extends Controller {

    /**
     * load parent controller
     */
    function Form()
    {
        parent::Controller();
        /**
         * Form must be submitted
         */
        if(!isset($_POST['sent']) || $_POST['sent'] != 1)
        {
            if(isset($_POST['ajax']) && $_POST['ajax'] == 1)
            {
                echo 0;
                exit;
            }
            else
            {
                redirect('');
            }
            
        }
    }
...

When redirect() is called the site redirect to 'site/news/', it should go to 'site/'. I can't figure out what's going on here, can anyone shine some light?

Cheers,
gevans

EDIT
----
Should have mentioned that I include wordpress in the CI index.php file;

Code:
<?php

/*
|---------------------------------------------------------------
| INCLUDE WORDPRESS LOADER FILE
|---------------------------------------------------------------
|
| Wordpress loader file must be included before the CI front controller.
| Loading after causes issue with Wordpress thinking it's not installed
| or returning a 404.
|
*/
    $wp_header = './news/wp-blog-header.php';
    $wp_header_path = realpath($wp_header);
    define('WP_USE_THEMES', false);
    require($wp_header_path);



/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL.  For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit:  http://www.php.net/error_reporting
|
*/
    error_reporting(-1);

/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same  directory
| as this file.
|
| NO TRAILING SLASH!
|
*/
    $system_folder = "system";

/*
|---------------------------------------------------------------
| APPLICATION FOLDER NAME
|---------------------------------------------------------------
|
| If you want this front controller to use a different "application"
| folder then the default one you can set its name here. The folder
| can also be renamed or relocated anywhere on your server.
| For more info please see the user guide:
| http://ellislab.com/codeigniter/user-guide/general/managing_apps.html
|
|
| NO TRAILING SLASH!
|
*/
    $application_folder = "application";

/*
|===============================================================
| END OF USER CONFIGURABLE SETTINGS
|===============================================================
*/


/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}

/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT        - The file extension.  Typically ".php"
| SELF        - The name of THIS file (typically "index.php")
| FCPATH    - The full server path to THIS file
| BASEPATH    - The full server path to the "system" folder
| APPPATH    - The full server path to the "application" folder
|
*/
define('EXT', '.php');
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('FCPATH', str_replace(SELF, '', __FILE__));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
|---------------------------------------------------------------
| LOAD THE FRONT CONTROLLER
|---------------------------------------------------------------
|
| And away we go...
|
*/
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

/* End of file index.php */
/* Location: ./index.php */
#2

[eluser]InsiteFX[/eluser]
Code:
redirect('site', 'refresh');

InsiteFX
#3

[eluser]gevans[/eluser]
Thanks for that but it setll redirects me to;

site/news/




Theme © iAndrew 2016 - Forum software by © MyBB