I have this laravel application deployed on server with apache. Initially the app was released for nginx, so no .htaccess was provided to the app.
I got accross some issues:
in the root of the subdomain there is a file server.php that contains:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
When I am calling that file in browser https://portal.eofs.dev/server.php I can see the content of the app yet without any style, and there are plenty of errors in console.
Any of the solutions tried do not load the app as it should.
I have also tried to move the subdomain index to public/ and following .htaccess rules:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L,QSA]
and
`RewriteEngine On
RewriteBase /
RewriteRule ^$ public/index.php [L]
RewriteRule ^((?!public/).*)$ public/$1 [L,NC]`
Any of the solutions tried do not load the app as it should.
Related
I used Laravel 9 and Inertia.js + Vuejs and the project has been deployed to the cpanel. When I access to the site and it threw an error saying Not Found with code 404 so then I added a new file - .htaccess outside the public folder and the error existed. I tried to access to public folder like this https://imapp.asomaningministries.com/public and it worked but I don't want anyone to eventually access to this folder. So can I hide it?
You can try to set the document root directory as 'public' directory on the domain settings page of cPanel.
or you can use .htaccess file like that;
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
Ok, this is what is happening.
I've created a small laravel app (actually, still it's on the development stage).
When I upload it to the server (shared hosting managed through cPanel) I've deployed it to a subfolder inside the main website.
There is the main website (a WordPress) on the server's public_html folder, so I created a subfolder where I put my app.
Now, when you request http://oursite.com you reach the Wordpress site.
And when you request http://oursite.com/laravelapp you reach the initial page of the laravel app.
However, when I try to browse any page into the app, the routing returns me to routes inside the root web folder.
For example, if I push the login button, the petition to http://oursite.com/laravelapp/login redirects to http://oursite.com/login, and obviously, the page load fails
The funny thing is that if I reach directly public pages, it seems to work fine.
If I directly request http://oursite.com/laravelapp/public/index.php and push the same login button, a request to http://oursite.com/laravelapp/public/index.php/login is made, and it works!! Even JS and CSS links are correctly detected on that request!!
I suspect this is probably something quite stupid that I cannot see now because I'm too tired, but I will really appreciate any insight on the matter.
The index.php on my laravelapp folder is the following:
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
And this is the code of the .htaccess file inside /laravelapp/public folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Maybe I would be able to fix this using a subdomain like myLaravelApp.oursite.com?
Ok.
I fixed this problem copying the .htaccess on laravelApp/public to laravelApp.
It seemed that the root folder needed some type of redirection, and this worked like a charm.
Successfully deployed my laravel application in shared hosting.
Well some pages also I can see in server.
But unable to see some pages in server, but can see on local host.
I have tried many solutions available .. but could not able to fix it.
domain.com/admin/home can be viewed on server.
but domain.com/admin/postjob has 500 error on server, but working fine in local host.
Laravel folder is copied under root and the contents of laravel/public is copied to public_html/
Lets first check routes.
//Admins Index Page
Route::get('/admin/home', 'admin\AdmhomeController#index')->name('admin.home');
//Job Posting by Admin - View
Route::get('/admin/postjob', 'JobsController#pjbyadm')->name('admin.postjob');
Lets see Controller - JobsController
//Post Job by Admin
public function pjbyadm(Request $request){
$auth = Auth::guard('admin');
if ($auth->check()){
//return view('admin.CRjob_ajob'); tried this first
return \view('admin.CRjob_ajob');
}
else {
return redirect('/mikeadmin');
}
Folder structure for views
Resources --> admin --> CRjob_ajob
.htaccess file in public_html folder looks like following.
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php71” package as the default “PHP” programming language.
<IfModule mime_module>
AddType application/x-httpd-ea-php71 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
server php file has
//require_once __DIR__.'/public/index.php';
require_once __DIR__.'../public_html/index.php';
Using laravel 5.8 version.
Expected to see the page admin/postjob, which is working fine in local host.
Try to run php artisan cache:clear before uploading to server then re upload or another solution is add this to your route
Route::get('/clear-cache', function() {
Artisan::call('cache:clear');
return "Cache cleared";
});
then call domain.com/clear-cache
I want to run the codeigniter project which I am currently working on in localhost I setup each and everythng accordingly
$config['base_url'] = 'http://localhost/site';
$config['index_page'] = '';
its works fine in my office but when i bought it home to work more on off days I started getting errors it only shows the home or index page and when i navigate to other pages it displays 404 object not found
just displays the home page all the other routes not working
please help
Reasons can be
You might have copied the code in different CodeIgniter version.
Some code standard differs from version to version.
Might be because of database.
Create .htaccess file and put below code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
I have gotten a live chat system written in codeigniter, and I want to integrate my WebSite, which is written in Cakephp him.
I installed the "/ livechat" folder webroot, I modified the livechat file / application / config / config.php and I put :
$config['base_url'] = 'http://exemple.com/livechat/';
Then I modified the .htaccess file in the folder "/livechat" :
RewriteEngine On
RewriteBase /livechat
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1
But when I run the live chat with the address "http://exemple.com/livechat/" I get an error: 404 Page Not Found
Can someone help me please?
thank you in advance