在 Yii2 中从 URL 隐藏网页 [英] Hide web from URL in Yii2

查看:53
本文介绍了在 Yii2 中从 URL 隐藏网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了 这个问题.我已按照建议将应用程序文件和文件夹移至上一级.

I have followed answer described in this question. I have moved Application files and folder to one level up as suggested.

public_html/basic/web,config 等.public_html/web,config 等.

通过修改这些配置从 url 中删除 index.php:

Removed index.php from url by modifying these configuration:

config/web.php

config/web.php

'urlManager' =>[
        'enablePrettyUrl' => true,
        'showScriptName' => false,
    ],

web 文件夹中的 htaccess 文件

htaccess file in web folder

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

所以现在我的网址是 example.com/web/controller/action

如何在上面的 url 中隐藏网页?我无权访问 apache 配置文件.

How can I hide web from the url above? I don't have access to the apache configuration file.

推荐答案

我的答案仍然有效 :).

My answer still stands :).

您走对了,将所有内容向下移动 1 个目录.现在你在 public_html 中复制了整个 yii2 应用程序,你应该将它向下移动 1 个目录.然后将您在 web 中的所有内容复制到 public_html 中.通过这样做,您的所有脚本都不会暴露在网络上,只会暴露 1 个 index.php,这是设置它的正确方法.

You are on the right track, move everything 1 directory lower. Right now you copied the entire yii2 application in public_html, you should move it 1 directory down. Then copy everything you have in web in public_html. By doing this all your scripts are not exposed to the web, only 1 index.php will be exposed and that is the proper way to have it set up.

这也是 yii 的主要教程,它告诉你如何去做 https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md

Also this is the main tutorial for yii that tells you how to do it https://github.com/yiisoft/yii2/blob/master/docs/guide/tutorial-shared-hosting.md

不要害怕这样做,服用蓝色药丸(或者是红色药丸):).

Do not be afraid of doing this, take the blue pill (or is it red) :).

这篇关于在 Yii2 中从 URL 隐藏网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆