我已遵循中描述的答案这个问题 https://stackoverflow.com/questions/27178364/yii-2-0-hiding-basic-web-from-the-url-along-with-the-index-php。我已按照建议将应用程序文件和文件夹移至上一级。
public_html/basic/web,config etc..
to public_html/web,config etc..
通过修改以下配置从 url 中删除 index.php:
配置/web.php
'urlManager' =>[
'enablePrettyUrl' => true,
'showScriptName' => false,
],
web 文件夹中的 htaccess 文件
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
所以现在我的网址是example.com/web/controller/action
如何隐藏上面的网址?我无权访问 apache 配置文件。
我的答案仍然有效:)。
您走在正确的轨道上,将所有内容向下移动 1 个目录。现在您已将整个 yii2 应用程序复制到 public_html 中,您应该将其向下移动 1 个目录。然后将 web 中的所有内容复制到 public_html 中。通过这样做,您的所有脚本都不会暴露在网络上,只有 1 个 index.php 将被暴露,这是设置它的正确方法。
这也是 yii 的主要教程,告诉你如何做https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md
不要害怕这样做,服用蓝色药丸(或者它是红色的):)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)