Internal server error when set up Laravel - php

I try to make a site using Laravel. When I put Laravel to "www" folder and browse
localhost/laravel/public
then I get a internal server error.
In error log display the following message.
/var/www/laravel/public/.htaccess: Options not allowed here
before put a post I saw similar problem here https://stackoverflow.com/questions/21097240/ and I didn't see any solution.
This is my .htaccess file
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

You have a .htaccess file in the directory /var/www/laravel/public with an Options directive in the wrong place.
You can only use the Options directive in a <directory> block.
You need to remove it, move it to the correct place or otherwise edit the file to correct the error.
See the Apache reference here

Related

Laravel and Apache2 : unable to correctly use redirects

I have an issue with Laravel. On an intranet Apache 2.4.10 Webserver runing with Debian 8.5, named fmbsrv130, I would like to install a Laravel Project named sentinelle.
So Laravel installation is OK, I can access to it with http://fmbsrv130/sentinelle/ (I have the welcome page of Laravel). But if I try to go to http://fmbsrv130/sentinelle/1 (that does not exists), I have 404 from Apache2 that says "The requested URL /home/webadmin/sentinelle/public/index.php was not found on this server." If I try to access http://fmbsrv130/sentinelle/index.php/1 I have the 404 from Laravel : "Sorry, the page you are looking for could not be found.
1/1 NotFoundHttpException in RouteCollection.php line 161: ..."
rewrite_mod is correctly enabled in Apache.
Here is config file of Apache (000-default.conf in sites-available) :
Alias "/sentinelle" "/home/webadmin/sentinelle/public/"
<Directory "/home/webadmin/sentinelle/public/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
For testing, if I try to modify .htaccess file from public folder of Laravel with
RewriteEngine On
RewriteRule ^.*$ htaccess_tester.php
(htaccess_tester.php is a file that is used to test content of .htaccessfile (see it on GitHub) and is currently into public folder), I have Apache2 404 error message The requested URL /home/webadmin/sentinelle/public/htaccess_tester.php was not found on this server.
Is it an issue from .htaccess file OR an issue from Apache2 config OR an issue from Laravel config OR a file access right ?
is your mod_rewrite enabled on your apache2 please confirm it should be enabled to .htaccess work and in your .htaccess file add default laravel .htaccess content
<IfModule mod_rewrite.c>
<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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
also if that doesn't work try to remove your index.php out of public directory and place it in root directory at /sentinell and modify .htaccess to RewriteRule ^ public/index.php [L] that should do the trick
OK so finally I found a solution by doing some modifications : first one is .htaccess file into public folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /sentinelle/
# 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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
(Adding RewriteBase /sentinelle/)
And the second one was into default.conf Apache file :
Alias /sentinelle /home/webadmin/sentinelle/public/
<Directory "/home/webadmin/sentinelle/public">
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
It solved the issue described into this topic, I'll open another one because now I have issue with last "/" in address :)

Multiple Choices error page in 1and1

I have done my project using laravel. I want to upload my project on 1and1. I set my directory structure on 1and1 is as '/directory' which contains index.html file which links to the other page in /directory/EngageV1/public/auth/login. but when I visits this page I am getting the error page as,
Multiple Choices
The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested.
Available documents:
/index.html (common basename)
Please consider informing the owner of the referring page about the broken link.
My .htaccess file looks like,
<IfModule mod_rewrite.c>
<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>
If enter url as /directory/EngageV1/public/ then it shows me the welcome page which I have set in routes.php file for route as '/'. Only this page works fine,I don't know what to do, Please give any suggestion.
Replace default contents in your .htaccess file under your the public
folder with the following.
RewriteBase /
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
If you still have problems look at this tutorial about how to deploy a Laravel webapp to 1and1
I know this is is an very old topic, but it took us some time today to find out what's going wrong on an old 1and1 (now Ionos) server. Turned out, the "multiple choices" page doesn't com from Option +MultiViews / mod_negotiation, but from a module called mod_speling that's running there by default. You can disable it in the .htaccess file:
<IfModule mod_speling.c>
CheckSpelling off
</IfModule>

500 internal server error in Laravel 4

I am trying to migrate my laravel web app to hosting server, uploaded contents and changed the database configuration.
Then I pointed to my web browser like : www.mywebsite.com it will shows 500 internal server error
Is there any problem in my htaccess file. ?
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
or I am working with BITBUCKET GIT.is there any problem with GIT Usage. ?
Thanks & regards
Posting my own answer. Make sure your folders have 755 permission. I cleared this issue with permission. This is first thing do any others. You can get successful output.
No Issues with .htaccess and GIT.

How to replace -MultiViews behaviour in htaccess?

I am trying to catch ALL requests to files in a directory and it's subdirectories and to route them to one single file in a subdirectory. Here is what the htaccess directives look like:
Options -MultiViews
<IfModule mod_rewrite.c>
RewriteEngine On
# Excluding one directory
RewriteRule ^(excludedfolder)($|/).*\.(php)$ - [L]
# Redirect everything that is html or php to magicscript
RewriteRule \.(php|html|phps)$ /excludedfolder/magicscript.php [L]
RewriteRule ^/?$ /excludedfolder/magicscript.php [L]
RewriteRule ^/?index.php$ /excludedfolder/magicscript.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . excludedfolder/magicscript.php [L]
</IfModule>
This works on the mostpart of systems.
If i call someserver.com/testfile.php, it is properly routed to magicfile.php. If i call someserver.com/testfile, it also is properly routed to magicfile.php. The same for subfolders: If i call someserver.com/somefolder/testfile.php or someserver.com/somefolder/testfile, it is properly routed to magicfile.php.
But on some servers, it is not allowed to set the Options -MultiViews which causes the server to completely fail. If I remove the option, it still works, but it doesn't if I don't add the file extension.
How to redirect non existing files to magicfiles.php without having to use Options -MultiViews? Or how to detect if it is allowed to set the option in php?
Thanks for your help!
Maybe the server do not support Options -MultiViews http://httpd.apache.org/docs/2.2/mod/core.html#options

Routes works on localhost but not on production server

I have a fresh installation of Laravel. It works perfectly fine on my local machine. But on the server the routes doesn't work correctly.
Here's how the URL looks like on my localhost:
localhost/articles/14
But when I try the same URL on my production server it doesn't work. But it does work if I type the URL like this:
mydomain.com/index.php/articles/14
So, with the index.php in between it works fine. And the index route works without a problem. So it seems like some kind of redirect issue.
Here's how my .htaccess file looks like:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
I tried adding RewriteBase /mypath/ to the .htaccess without luck.
I have searched on Google and tried some suggestion without luck.
Check if mod_rewrite is enabled on your server.
Also, .htaccess may be disabled on your server for security reasons.
Try putting your mod_rewrite on your <VirtualHost> or <Directory> section.

Categories