![](/img/trans.png)
[英]I need laravel website to open in https without public in url, how can I do it?
[英]how can i use laravel website in CWP (Centos-Web-Panel). without public folder in url?
嗨,我想更改服务器面板为 CWP centos-web-panel
网站的根目录。 我找到了一个解决方案,说在httpd.conf
更改DocumentRoot
和directory
,但我无法更改它,因为我的很多网站都使用此服务器。 我想更改我的网站之一中的根文件夹。 另外,我找到了另一个解决方案,它说编辑文件。
# nano /etc/httpd/conf.d/your_site.conf
并将此代码添加到文件中
<VirtualHost *:80>
DocumentRoot /var/www/html/your_site/public
ServerName your_domain
<Directory /var/www/html/your_site/>
AllowOverride All
</Directory>
</VirtualHost>
但不工作。 我怎么能做到这一点? 是否有任何解决方案或使用.htaccess
或自己的laravel
模板?
所以我想改变/public_html/
到/public_html/public/
中centos-web-panel
我使用Nginx的
去 :
WebServer Settings -> Conf Editor -> Apache -> /usr/local/apache/conf.d/vhosts/
搜索mydomain.ssl.conf & mydomain.conf并单击编辑
搜索 DocumentRoot 并更改它
从:
DocumentRoot /home/username/public_html
到:
DocumentRoot /home/username/public_html/public
之后不要忘记重新启动Apache。
完毕
将此代码添加到.htaccess中
RewriteEngine开
RewriteRule ^(.*)$ public/$1 [L]
并将index.php文件复制到根文件夹,然后按照以下步骤进行操作: https://hellocoding.wordpress.com/2014/05/17/how-to-remove-public-from-url-in-laravel/ https:// hdtuto。 COM /条/ laravel -删除-公众从-URL-使用,htaccess的
您需要执行以下操作来指向您的应用程序,而无需在URL
公开:
将您的server.php重命名为index.php
并从公用文件夹中复制您的.htaccess
文件,并将其并行粘贴到index.php
(以前是server.php
)
要隐藏.env
文件,您需要在.htaccess
文件中添加以下行
# Disable index view
Options -Indexes
# Hide a specific file
<Files .env>
Order allow,deny
Deny from all
</Files>
我更喜欢这个答案。 这更安全。 无需重定向。 创建一个文件夹中的public_html也许foldername
然后将所有文件和文件夹从public_html
的foldername
的所有文件和文件夹后,这一举动public
laravel文件夹中public_html
开放index.php
和编辑这样。
require __DIR__.'/../vendor/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';
至
require __DIR__.'/foldername/vendor/autoload.php';
$app = require_once __DIR__.'/foldername/bootstrap/app.php';
然后使用.htaccess
隐藏.env
文件
完
如果您有权使用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.