1

This is a bit of an odd situation but I have a nav link on my laravel site that I changed to go directly to an aws bucket file

<li><a href="www.awslink/thisLink.com">Images</a></li>

However, the old site had this nav direct to files in the local site storage (site->public->images->assets) at www.mysite.com/images

Is there a way so that if someone has a bookmark or hardcodes the link www.mysite.com/images it will direct to that aws link? Or can I set a route to go straight to it in that instance?

I set a route with a redirect for Get::'Images' to the link but the issues is I have the folder of the same name in my public folder. Can I ignore that folder?

new route:

Route::get('Images', function(){
    return redirect('https://aws.images');
});
Geoff_S
  • 4,917
  • 7
  • 43
  • 133
  • Are you using apache or nginx? – Sky Jun 28 '19 at 21:17
  • It's hosted on IIS windows server using Apache. I have other pages where getting a root file is fine, but in this case I have something hardcoded to site.com/Images (third party) that I can't change, so I need the route to match that but ignore that I have that directory. I actually changed the name of the directory but now just get 404 – Geoff_S Jun 28 '19 at 21:22
  • @Sky updated with my new route too – Geoff_S Jun 28 '19 at 21:22

1 Answers1

1

Because a folder with that name exists in your public directory it's being handled by your web server first and doesn't let Laravel know about it. So you have to config your web server to redirect to your new location.

As you're using apache you have to add this line to .htaccess file:

Redirect 301 /images https://aws.images
Sky
  • 4,244
  • 7
  • 54
  • 83
  • SO that makes sense, but if I changed the name of the folder it should work without this right? Now that I've changed the name of the folder it no longer hits that directory but I do get a 404 now – Geoff_S Jun 28 '19 at 21:34
  • @TomN. It's probably because of your Apache configuration. Your apache is probably using alias for `/images` route to point it to another directory. Take a look at https://stackoverflow.com/questions/15770778/configure-apache-conf-for-alias and https://httpd.apache.org/docs/2.4/mod/mod_alias.html – Sky Jun 29 '19 at 09:06