重定向:: to_route('admin')重定向到laravel 3中的公用文件夹

时间:2013-09-07 04:24:17

标签: php redirect laravel laravel-3

我在一年前在laravel 3中创建了一个页面并且我正在更改我的主机,我在使用域名回复公共文件夹时遇到了Mod_rewrite的问题,我通过更改paths.php文件使公共文件夹成为html_public的index.php。

Everithing似乎运行正常,但是当我在控制器中进行重定向时,我得到了公共文件夹的URL,例如:

重定向:: to_route( '管理员');

带我去

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

我需要那个公共场所的网址。

是否有其他方法可以重定向到该路由,或者是在没有公用文件夹的情况下进行重定向的简单方法?

1 个答案:

答案 0 :(得分:0)

在config / application.php中 只需将静态网址或空网址更改为以下

即可

为您和您正在使用的应用程序功能(如重定向)

检测正确的URL
<?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,

并保留文件的其余部分

相关问题