0

像一年前一样,我在 laravel 3 中创建了一个页面并且我更改了我的主机,我在为公共文件夹制作域答案时遇到了 Mod_rewrite 问题,我通过更改 paths.php 文件和 index.php 将公共文件夹设为 html_public .

一切似乎都很好,但是当我在控制器中进行重定向时,我会得到带有公共文件夹的 url,例如:

重定向::to_route('admin');

带我去

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

我需要那个没有公众喜爱的网址。

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

4

1 回答 1

0

在 config/application.php 中,只需将静态 url 或空的 URL 更改为以下

它为您和您正在使用的应用程序功能(如重定向)检测正确的 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,

并将文件的其余部分保持原样

于 2013-10-01T14:37:26.517 回答