1

嗨,我想更改服务器面板为 CWP 的网站的根目录centos-web-panel。我找到了一个说 change DocumentRootand directoryin的解决方案,httpd.conf但我无法更改它,因为我的很多网站都使用此服务器。我想更改我的一个网站中的根文件夹。另外,我找到了另一个解决方案,它说编辑文件。

# 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更改in i

4

5 回答 5

2

您需要执行以下操作以在不公开的情况下指向您的应用程序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>
于 2019-03-07T07:21:52.633 回答
2

在 .htaccess 中添加此代码

重写引擎开启

RewriteRule ^(.*)$ public/$1 [L]

并将 index.php 文件复制到根文件夹并按照步骤 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

于 2019-03-07T07:09:59.190 回答
2

去 :

WebServer Settings -> Conf Editor -> Apache -> /usr/local/apache/conf.d/vhosts/

搜索mydomain.ssl.confmydomain.conf并单击编辑

搜索 DocumentRoot 并更改它

从:

DocumentRoot /home/username/public_html

至:

DocumentRoot /home/username/public_html/public

之后不要忘记重新启动 Apache。

完毕

于 2021-07-07T05:35:46.803 回答
0

我更喜欢这个答案。哪个更安全。并且无需重定向。在 public_html 中创建一个文件夹,foldername然后将所有文件和文件夹从laravel 文件夹移动public_htmlfoldername之后,然后像这样打开和编辑它。publicpublic_htmlindex.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';

然后隐藏.env文件.htaccess

结束

于 2019-03-07T09:12:52.610 回答
0

如果您有权访问 ssh 删除 public_html 文件夹 rm -rf public_html/ 创建到公共文件夹 (laravel) 的快捷方式,我们将把 laravel 放在同一级别 public_html ln -s laravel/public public_html 现在完成

于 2019-09-01T22:41:39.357 回答