Laravel 5 internal server error after moving to the server - .htaccess

My laravel 5 project is works well on localhost. After moving the project to the server it shows an internal server error.
Error message
The server encountered an internal error or misconfiguration and was unable to complete your request.
I checked the requirements. All requirements are correct.
PHP = 5.5
Mcrypt PHP Extension = Enabled
OpenSSL PHP Extension = Enabled
Mbstring PHP Extension = Enabled
Tokenizer PHP Extension = Enabled
Both .htaccess files on the root and public folder are same,
<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 tested by removing the both .htaccess files but it still shows the Internal server error.
How Can I fix this issue ? Any suggestions ?

check if mod_negotiation is enabled. I had the same issue just now

I have faced the same issue while migrating the shared server . The solution that worked me is as below.
Let's say there is laravel folder called test which contains folder structure of laravel.
I have use 2 different .htaccess file
1) one in the root folder of the (installed) laravel , i.e Along with test folder with content as below.
RewriteEngine On
RewriteCond %{REQUEST_URI} !^test/public
RewriteRule ^(.*)$ test/public/$1 [L]
2) One in the public folder i.e inside test/public with content as below.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
It worked for me.

Related

Getting internal error when trying to access website live

Getting following error
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at webmaster#api.example.com.au to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
I pushed live codeigniter project, I updated .htaccess , database file, config file.
.htaccess file contains following code
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|css|js|images|robots\.txt)
RewriteRule ^(.*)$ index.php?$1 [L]
Options -Indexes
The Codeigniter project is inside api.websiteName.com folder and it is not in public_html, if i remove the index.php and htccess file and upload "index.html" file for testing purpose , then index.html works fine but when I upload index.php and .htaccess files back , it says Internal server error 500, There are many answers for same question, I followed answers and did update .htaccess file but nothing works. Folder permissions set as 755 but still getting same error. Any help would be much appreciated.
PHP verison is higher than 5.6
You can try this .htaccess file in your code.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
<IfModule mod_headers.c>
Header add Access-Control-Allow-Origin "*"
</IfModule>
<IfModule mod_env.c>
SetEnv CI_ENV development
</IfModule>
I hope it will help you..

Laravel isn´t working on Shared Server based on Linux

does anybody know how to setup Laravel that it´ll work on a shared Server based on Linux?
I´ve tried default and alternative .htaccess files:
when I type a url which doesn´t exists and isn´t defined in routes.php I get this:
.
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error. More information about this error may be available in the server error log. Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
when I type a url to a folder which exists but isn´t defined in routes.php I get a Redirect Loop
when I type a url to a file which exists but isn´t defined in routes.php I get same Error like first one
here the .htaccess files I´ve tried with (both behave same)
<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>
.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

htaccess : wildcard folders and url

I have some domain for example http://domain.com
http://domain.com/sport -> Folder actually exits
http://domain.com/sport/123/ - > Folder dont exist
http://domain.com/sport/123/hello.html - > file dont exist
So when http://domain.com/sport/123/ or
http://domain.com/sport/123/hello.html is visited..Instead of throwing not found error it must show the content of the first folders index.php , that is in this example it must show the contents of http://domain.com/sport/index.php
I tried below code.but it throws 500 internal error
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/.*$ /$1/index.php [L]
Do you still get a 500 internal server error if you wrap all of your rewrite rules inside an IfModule container? E.G.
<IfModule mod_rewrite.c>
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/.*$ /$1/index.php [L]
</IfModule>
If you stop getting the error, but rewriting is still not working, that means you have to turn on the rewrite module. How this is done is entirely dependent on your setup, your hosting services setup, and/or whether you have access to the httpd.conf file.

Laravel 4 Internal Server Error 500 on Hostgator

I have a Laravel 4 app deployed on shared Hostgator server.
When I navigate to:
http://mydomain.com/laravel/public/
I can see the Laravel splash screen.
but when I try to access any other route to, say, /users or /posts I am getting
Internal Server Error 500
http://mydomain.com/laravel/public/posts
Controller:
public function index()
{
$posts = $this->post->all();
return View::make('posts.index', compact('posts'));
}
In Routes.php:
Route::resource('posts', 'PostsController');
I use Jeffrey Way's Generator to scaffold the posts entity.
The same works fine on my local machine. Controllers don't contain any logic, they only output the fetched data.
Error logs are empty.
Any ideas what to check? .htaccess, maybe?
Here is what I have there:
AddType application/x-httpd-php53 .php
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
As mentioned in comments, a 500 error without a corresponding log file entry from the application logger is likely an .htaccess file issue.
Since the OP found the issue is related to the rewrite (and not the directive to use php 5.3):
Since this is probably a common issue on Hostgator, you should check with their help docs.
However, my first stab at a fix would be to add a RewriteBase directive:
RewriteBase /
So it would look like:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Note that this assumes you're running the web application form the web root and not a sub-directory.

.htaccess and internal server error

I've been trying to set up .htaccess to create clean PHP URL. My goal is to achieve clean URLs within the folder CL.
.htaccess:
# Use PHP5 Single php.ini as default
AddHandler application/x-httpd-php5s .php
<IfModule mod_rewrite.c>
# This is the initialization
# For security reasons, Option followsymlinks cannot be overridden.
#Options +FollowSymLinks
Options +SymLinksIfOwnerMatch
RewriteEngine On
RewriteBase /
# /CL/var1/var2/var3
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^CL/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /CL/index.php?var1=$1&var2=$2&var3=$3 [L,QSA]
# /CL/var1/var2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^CL/([a-zA-Z0-9\-]+)/([a-zA-Z0-9\-]+)/?$ /CL/index.php?var1=$1&var2=$2 [L,QSA]
# /CL/var1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^CL/([a-zA-Z0-9\-]+)/?$ /CL/index.php?var1=$1 [L,QSA]
</IfModule>
However, for some reason, I get a 500 internal server error when y enter the folder CL. I've used similar .htaccess configurations in the past, but now its not working fore some reason.
Any ideas?
"I've used similar .htaccess configurations in the past, but now its not working fore some reason."
OK, so the ruleset works. I've just tested in on one my test VMs so it still works, so your problem isn't the mod_rewrite functionality in this .htaccess file. So where could it be?
Think laterally. A 500 status is usually a mod_rewrite loop. Have you got an .htaccess file in /CL? This could create a perdir indefinite loop.
Unfortunately DS suggestion of trying to get an answer on error_log content from a shared hosting provider for a $100 pa shared service is a no-no. Morale: set up a test VM on your PC to debug this stuff where you can get root access to the log as article here.

Resources