简体   繁体   中英

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

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

RewriteBase /

that worked for me.

All the best, M

I use Laravel 5.2, thanks, it works for me also, thanks I added RewriteBase to my .htaccess file

<IfModule mod_rewrite.c>
    RewriteBase /
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

This worked for me, just following contents are in my .htaccess

RewriteBase /

Options +FollowSymLinks
RewriteEngine On

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM