Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Laravel Routing for a specific folder/route

I'm wondering how to disable the routing on laravel for a specific directory?

I am hoping to run my main website off of laravel (I'm rewriting it into the framework), but I'd like to retain my current forum software! The problem is, when laravel sees the "localhost/forums" it looks for a forums controller or route. I'd like it to simply go to the literal /forums directory..?

like image 865
Mitchell M Avatar asked Aug 06 '13 08:08

Mitchell M


People also ask

What is the difference between route and URL in Laravel?

For a start it is using a named route. This means that the link between the form and its controller are not dictated by the url that the user sees. The next advantage is that you can pass additional parameters into the route helper and it will put those in the correct place in the form action.

What is routes folder in Laravel?

The Default Route Files All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by your application's App\Providers\RouteServiceProvider . The routes/web.php file defines routes that are for your web interface.

What is Routein Laravel?

Route is a way of creating a request URL of your application. These URLs do not have to map to specific files on a website. The best thing about these URLs is that they are both human readable and SEO friendly. In Laravel, routes are created inside the routes folder. Routes for the website are created in web.


2 Answers

I had to add this line in public/.htaccess

RewriteCond %{REQUEST_URI} !^/foldername

before this line (that redirects trailing slashes)

RewriteRule ^(.*)/$ /$1 [L,R=301]
like image 157
George D. Avatar answered Oct 23 '22 04:10

George D.


With Laravel 4 none of these solutions were working for me. I eventually solved it by placing

RewriteRule ^(directory-name) - [L]

before

RewriteRule ^(.*)/$ /$1 [L,R=301]

in public/.htaccess

like image 40
KyleT Avatar answered Oct 23 '22 04:10

KyleT