How to hide public from url in laravel 9 - laravel

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]

Related

Laravel root directory not public on Hostinger hosting

I currently host my Laravel website on Hostinger, but when I have a image on my page, the url doesn't go to website.com/public/img_url, but it goes to website.com/img_url, does anyone know how this works on Hostinger, and how I can fix this?
Currently my whole project is in my public_html, with no other folders besides it.
The right solution was changing my htaccess to:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
You should need to add a public inside asset function to access a public folder on the shared hosting server.
So you need to change the fetch path of files Example: asset('user/photo.jpg') to asset('public/user/photo.jpg') in each line of code where you need to fetch files from the public directory.

Codeigniter 3.1.11 unable to open welcome page

I have downloaded and using Codeigniter 3.1.11.
I have copied the same to as usual htdoc folder.
Tomcat is Binary Installed and service running and able to get
the Welcome page with http://localhost/CodeIgniter3111/index.php/welcome.
I have inserted in .htaccess as below.
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|images|js|css uploads|fevicon.png)
RewriteCond %{HTTP_COOKIE} ais=([a-z0-9-_]+)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-f
RewriteBase /CodeIgniter3111/
RewriteRule ^(.*)$ ./index.php/$1 [L]
and also removed the index.php from Config.
$config['base_url'] = 'http://localhost/CodeIgniter3111'; and added the base url as well.
As I type in url (http://localhost/CodeIgniter3111/welcome), I am
getting below error in browser.
Not Found
The requested URL /CodeIgniter3111/welcome was not found on this server.
I appreciate support in advance.
$config['base_url'] = 'https://localhost:8888/Your folder name';
your port number should be there

Codeigniter Project Not Working on localhost

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>

Codeigniter 404 not found error when accessing anything inside application folder

I am having a problem after hosting my codeIgniter project on live shared hosting server.
Before doing that, I changed few things on my local server.
.htaccess file-
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
.config.php inside config folder-
$config['base_url'] = '';
$config['index_page'] = '';
to let it work properly on my local server without writing index.php in URL. But when I moved it to live server, I changed base_url as-
http://crm.sachinartani.com
as I am hosting it on my subdomain, but it always output-
404 Page Not Found
The page you requested was not found.
I watched all videos on YouTube and traversed all questions of StackOverflow but none of the solutions helped me. There is a folder aside application folder namely inc which contains CSS and JS files I am using in my project. I am able to access those files by URL as - http://crm.sachinartani.com/inc but I cannot access any controllers and views like this.

Integrate Livechat System xritten in Codeigniter in Cakephp installation

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

Resources