Search code examples
phphttp-redirectlaravellaravel-3

Redirect::to_route('admin') redirecting to public folder in laravel 3


i made a page in laravel 3 like a year ago and im changing my host, i had problems with Mod_rewrite at making the domain answer to the public folder and i made the public folder the html_public by changing the paths.php file and index.php.

Everithing seems to work fine but when i make a Redirect in the controller i get the url with the public folder for example:

Redirect::to_route('admin');

Takes me to

http://www.Mydomain.com/public/admin

And i need that url witouth the public fonder.

Is there another way to redirect to that route or a easy way to make the redirect without the public folder?


Solution

  • in the config/application.php just change the static url or the empty one to the following

    which detect the right url for you and for your application function in use like redirect

    <?php
    if (empty($_SERVER['SCRIPT_NAME']) || $_SERVER['SCRIPT_NAME'] == "artisan") {
    $url = 'http://www.mydomain.com';
    } else {
    $url = 'http://' . $_SERVER['HTTP_HOST'] . str_replace('/index.php', '',  $_SERVER['SCRIPT_NAME']);
     }
    
    return array(
    
    /*
    |--------------------------------------------------------------------------
    | Application URL
    |--------------------------------------------------------------------------
    |
    | The URL used to access your application without a trailing slash. The URL
    | does not have to be set. If it isn't, we'll try our best to guess the URL
    | of your application.
    |
    */
    
    'url' => $url,
    

    and leave the rest of the file as is it