1

I have a route defined as follows:

Route::get('products/{name}', function($name) {
    return View::make('product')->with('name', $name);
});

The problem is that when this route is used, the current directory is changed to example.com/products/ which is horrendous, as that completely breaks the links (an image that pointed to images/nameOfImage.png now points to products/images/nameOfImage.png, which doesn't exist).

How can I prevent this?

General_Twyckenham
  • 2,061
  • 2
  • 18
  • 34

1 Answers1

1

Actually the problem is something else (It's because of relative URL), just try this:

<img src="{{ asset('images/nameOfImage.png') }}" />

Instead of directly using <img src="images/nameOfImage.png" />

The Alpha
  • 131,979
  • 25
  • 271
  • 286
  • Hmm, so that could work. The thing is that I have a lot of different files with probably hundreds of resources already linked directly. It would be much easier if there were another way to fix this – General_Twyckenham Jun 15 '14 at 21:06
  • ``, [check this](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base) and [this answer](http://stackoverflow.com/questions/1889076/is-it-recommended-to-use-the-base-html-tag) as well. – The Alpha Jun 15 '14 at 21:09
  • Welcome but it's better if you can avoid base, check other `SO` answer (The link is given in previous comment). – The Alpha Jun 15 '14 at 21:11