[英]how can i use laravel website in CWP (Centos-Web-Panel). without public folder in url?
hi, I want to change the root directory of my website which the server panel is CWP centos-web-panel
.嗨,我想更改服务器面板为 CWP
centos-web-panel
网站的根目录。 i find a solution that says change DocumentRoot
and directory
in httpd.conf
but I can't change that because a lot of my website using this server.我找到了一个解决方案,说在
httpd.conf
更改DocumentRoot
和directory
,但我无法更改它,因为我的很多网站都使用此服务器。 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?是否有任何解决方案或使用
.htaccess
或自己的laravel
模板?
so i want to change /public_html/
to /public_html/public/
in centos-web-panel
i using Nginx所以我想改变
/public_html/
到/public_html/public/
中centos-web-panel
我使用Nginx的
Go to :去 :
WebServer Settings -> Conf Editor -> Apache -> /usr/local/apache/conf.d/vhosts/
Search for mydomain.ssl.conf & mydomain.conf and click edit搜索mydomain.ssl.conf & mydomain.conf并单击编辑
Search for DocumentRoot and change it搜索 DocumentRoot 并更改它
From:从:
DocumentRoot /home/username/public_html
To:到:
DocumentRoot /home/username/public_html/public
Don't forget to restart Apache after that.之后不要忘记重新启动Apache。
Done完毕
Add this code in .htaccess 将此代码添加到.htaccess中
RewriteEngine On RewriteEngine开
RewriteRule ^(.*)$ public/$1 [L]
and copy index.php file to root folder and follow steps https://hellocoding.wordpress.com/2014/05/17/how-to-remove-public-from-url-in-laravel/ https://hdtuto.com/article/laravel-remove-public-from-url-using-htaccess 并将index.php文件复制到根文件夹,然后按照以下步骤进行操作: https://hellocoding.wordpress.com/2014/05/17/how-to-remove-public-from-url-in-laravel/ https:// hdtuto。 COM /条/ laravel -删除-公众从-URL-使用,htaccess的
You need to do the following thing to point your application without public in the URL
: 您需要执行以下操作来指向您的应用程序,而无需在
URL
公开:
Rename your server.php to index.php
and copy your .htaccess
file from public folder and paste it parallel to index.php
(which is previously server.php
) 将您的server.php重命名为
index.php
并从公用文件夹中复制您的.htaccess
文件,并将其并行粘贴到index.php
(以前是server.php
)
And to hide your .env
a file you need do add following lines in your .htaccess
file 要隐藏
.env
文件,您需要在.htaccess
文件中添加以下行
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env>
Order allow,deny
Deny from all
</Files>
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. 创建一个文件夹中的public_html也许
foldername
然后将所有文件和文件夹从public_html
的foldername
的所有文件和文件夹后,这一举动public
laravel文件夹中public_html
开放index.php
和编辑这样。
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
然后使用
.htaccess
隐藏.env
文件
Finish 完
如果您有权使用ssh删除public_html文件夹rm -rf public_html /创建快捷方式到公共文件夹(laravel),我们将把laravel放在同一级别public_html ln -s laravel / public public_html现在完成了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.