Reputation: 2757
I have a problem (obviously), I'm using Laravel 4.1 and I made a V2 of my website using Laravel, the V1 was a static website (no php, only a lot of html files and folders).
Now, I want to make 301 redirect because old users still have the old urls in bookmark and other websites still reference me with the old url. So when people go trough these old urls, I want them to be redirect on the new url ok (no problem with that) ?
In fact when I try to access to an old url in my V2 looking like a new route pattern.. OK i'm gonna explain more precisly. So imagine I had www.example.com/en/restaurants/, this is the path of the folder restaurants on my old website, now i have a route like this =>
Route::get('{$lang}/{$category}', PostController@getPosts)
And I type in my browser www.example.com/en/restaurants/.. My route won't work.. it will show me the folder content..
I hope you see what I mean !
Thank you everyone.
Upvotes: 0
Views: 1203
Reputation: 6208
It will serve real files and folders before it ever touches your routes. If you're using apache the, .htacess will tell it to only rewrite for paths that aren't actual paths, and the same goes for nginx.
There are ways to override this, but don't do it, as it can seriously affect the loading of assets and create a lot of nasty bugs.
What I would suggest, is do not have the original content in the laravel public directory. Best thing, would be to compile a list of all of the URLs and have a catch all route at the bottom of your routes file where you check if it is in the list, and redirect accordingly. It's annoying and a bit tedious, but it's the best option, honestly. Perhaps a config file?
<?php
return [
'oldurl' => 'newurl/route'
];
Upvotes: 1