Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel routes & .htaccess file not working on 1and1 hosting

My client recently purchased a linux 1&1 unlimited package from 1and1.com hosting company. I built the application for him in Laravel 4.2 framework. The application is working absolutely fine on my local machine as well as on my own VPS. But when I setup the files on my client host, it looks like .htaccess file is not working. Thats why, the laravel routes are not working and I'm constantly getting the 404 error message when trying to access different routes of the site.

I've researched a lot about this issue and find many people heading with the same issue but couldn't find the real solution to this problem.

Here is the .htaccess code:

<IfModule mod_rewrite.c>
  Options -MultiViews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
</IfModule>

I'm using Laravel 4.2

like image 812
Faizan Afzal Avatar asked Feb 25 '15 12:02

Faizan Afzal


People also ask

What are Laravel routes?

The route is a way of creating a request URL for your application. These URLs do not have to map to specific files on a website, and are both human readable and SEO friendly. In Laravel, routes are created inside the routes folder. They are are created in the web. php file for websites.

What is route in Laravel API?

To define the routes available in an API, register the API in your routes/api. php file as follows: JsonApi::register('default')->routes(function ($api) { $api->resource('posts'); $api->resource('comments'); }); If you prefer not to use the facade, use app("json-api")->register() instead.

What is the difference between web and API routes in Laravel?

In a Laravel application, you will define your “web” routes in routes/web. php and your “API” routes in routes/api. php. Web routes are those that will be visited by your end users; API routes are those for your API, if you have one.


1 Answers

I encountered the same problem on my 1&1 hosted solution. I suggest adding:

RewriteBase /

that worked for me.

All the best, M

like image 68
IceFire Avatar answered Oct 05 '22 06:10

IceFire