Laravel isn´t working on Shared Server based on Linux - .htaccess

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]

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..

.Htaccess not redirecting to a subfolder in www

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /reminder-app/
#Prevent Indexing
Options +FollowSymLinks -Indexes
#Handle Controller
RewriteCond ${REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /reminder-app/index.php [R=301, L]
</IfModule>
Im trying to redirect my localhost / to a subfolder called reminder-app
i put .htaccess in www and that is my code. am i missing something because it display error :
Server error! The server encountered an internal error and was unable
to complete your request. Either the server is overloaded or there was
an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500 localhost Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/7.1.1
Replace this line RewriteCond ${REQUEST_FILENAME} !-f
with this this RewriteCond %{REQUEST_FILENAME} !-f So , don't use $ in front of Server-Variables like {REQUEST_FILENAME} and use % instead.
Then this [R=301, L] should be like this [R=301,L] without space between , and L
Clear your browser cache then test it .

Laravel 5 internal server error after moving to the server

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.

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.

Resources