You can go to the Domains section of cPanel then edit the document root of your domain to point to the public directory of your project instead of the root directory.
How to get rid of public URL in your laravel project deployed on server cPanel "yourcpanelname/supportcrm/public"
In cPanel I have uploaded my laravel project but now when I enter my cPanel url. It list me all structure like
app
public
routes
etc...
when I click on public then it runs but I want to access directly with site name..How can I do this.. should I have to create subdomain or is any other method.. because using creating subdomain its working...please let me know it there is any other suggestion instead of subdomain..
@takdw I have one confusion Is it a good idea to chane .htaccess file and index file in laravel..? I google it most of article and video tutotrial say about change .htaccess and make change in index.php file... plz let me know...
That's not how I like to deploy my apps. I like to keep the file structure the same. Changing the document root is the easiest fix for me.
its NOT a good idea to change index.php and htaccess. Those guides should be taken down as they promote poor security
@Snapey Hello. Following takdw above, how do you remove /public from the url. ??? Thanks
@ErikRobles change the document root of your webserver
@snapey @takdw could you please tell me how can I run my project without /public ? http://my_domain/supportcrm/public/ in cPanel I found some solution like this...is this good.. for security reason?
Rename server.php in your Laravel root folder to index.php
Copy the .htaccess file from /public directory to your Laravel root folder.
https://stackoverflow.com/questions/28364496/laravel-5-remove-public-from-url
@neeraj1005 copy all the project and make it in a new folder ( exp: project), after that copy all files from public file and put them in the root folder of server .
You get this in root folder of server
project
index.php
.htaccess
composer.json
.....
After that change this two lines in your index.php file
require __DIR__.'/"project"/vendor/autoload.php';
require __DIR__.'/"project"/vendor/autoload.php';
@malektn I think It is not a good way to changes with framework flow...?
@takdw @snapey @malektn Also I have found another solution from stackoverflow https://stackoverflow.com/a/54275198/8455396
Create .htaccess file in root directory and place code something like below
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^ [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>
In my localhost its running properly but my another problem is.. when error page occured how to hide you environment variable data...because in error page it show all data your database name with password
@neeraj1005 change envirement variable in .env file
APP_ENV=local
to
APP_ENV=production
And you should make your Apache is secure :
@neeraj1005 you can do like this,
say for example if your domain is xyz.com means, upload all your project files in that domain.
now move inside you public folder and cut all files and paste outside.
means: xyz.com->public->all files to xyz.com->those files
so the index files in your public will come outside. now open your index file and change it as,
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
to
require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';
This works fine.. There is no need of change in htaccess file
Change the document root to be the public folder, as suggested by @takdw
Please or to participate in this conversation.