Answer a question

hi, I want to change the root directory of my website which the server panel is CWP centos-web-panel. i find a solution that says change DocumentRootand directory in httpd.conf but I can't change that because a lot of my website using this server. I want to change the root folder in one of my websites. also, I find another solution which said edit the file.

# nano /etc/httpd/conf.d/your_site.conf

and add this code to the file

<VirtualHost *:80>
DocumentRoot /var/www/html/your_site/public
ServerName your_domain

<Directory /var/www/html/your_site/>
AllowOverride All
</Directory>
</VirtualHost>

but not working. how I can do that? are any solution for that or with .htaccess or own laravel template?

so i want to change /public_html/ to /public_html/public/ in centos-web-panel i using Nginx

Answers

I prefer this answer. which is more secure. and no need to redirect. create a folder in the public_html maybe foldername then move all of files and folders from the public_html to the foldername after that move all files and folders from public laravel folder to public_html open index.php and edit that like this.

require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

to

require __DIR__.'/foldername/vendor/autoload.php';
$app = require_once __DIR__.'/foldername/bootstrap/app.php';

then hide .env file with .htaccess

Finish

Logo

开发云社区提供前沿行业资讯和优质的学习知识,同时提供优质稳定、价格优惠的云主机、数据库、网络、云储存等云服务产品

更多推荐