douben6670 2014-07-04 23:39
浏览 273

如何在Laravel中创建相对路径URL?

I need to use relative paths for my site (Lets just say for reasons I don't want to get into it has to be relative).

Currently I'm using the following in my site:

# url to controller
{{  Form::open(array('url' => 'users/signin') }}

# url to controller
 <li><a href="{{action('UsersController@getLogout')}}" class="navbar-brand "> <span class=""></span> Logout </a></li>

# url to style
{{ HTML::style('css/main.css')}}

I've tried others too but all of them constructs absolute URLs such as:

http://localhost:8888/mysite/users/logout

In vanilla PHP i could place relative paths like this:

<li><a href="../search/">Search</a></li>

I abandoned HTML::style() and used relative URLs on my css,js etc. like this which works:

<link rel="stylesheet" type="text/css" href="/css/main.css">

However how can do this for links to controller methods?

  • 写回答

1条回答 默认 最新

  • dongsun5330 2014-07-05 00:01
    关注

    It seems like this isn't possible out-of-the-box with Laravel 4. I did find someone's modification of the URL class in Laravel which allows this, but it does mean you are using third-party code for otherwise integrated functionality.

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!