Yii的2.0隐藏/基本/从URL网页一起的index.php [英] Yii 2.0 hiding /basic/web from the URL along with the index.php

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

问题描述

大量的四处撒网如何隐藏index.php的信息,从您的Yii 2.0应用程序的URL,但是,我想要做的,是要还从URL中删除/基本/网络/。 /基本/网络是从中运行应用程序的目录中,并且我到目前为止是如下的配置。那进入配置文件:

Plenty of information around the net on how to hide the index.php from your Yii 2.0 application URL, however, what I'm trying to do here is to also remove the '/basic/web/' from the URL. /basic/web is the directory from which the application is running and the configuration that I have so far is the following. That goes into the config file:

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

这是我有/ web文件夹在我的htaccess文件:

And this is my htaccess file that I have within the /web folder:

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

到目前为止,一切都很好,我可以访问什么直接调用 mysite.com/basic/web/controller/action 。我需要做什么做的,虽然删除/基本/网络,以使URL成为只是简单的 mysite.com/controller/action

So far, so good, I can access something directly calling mysite.com/basic/web/controller/action. What do I need to do though to remove the /basic/web so that the URL becomes just simple mysite.com/controller/action?

任何提示欢迎,非常感谢!

Any tips welcome, thanks!

编辑:我在寻找一种方式不碰,因为我没有访问它的Apache配置文件

I'm looking for a way without touching the apache configuration file as I don't have access to it.

推荐答案

您应该定义以另一种方式你的Apache配置。您的网站应指向{文件夹} /基础/网络,而不是{文件夹}。

You should define your apache configuration in another way. Your site should point to {folder}/basic/web and not to {folder}.

由于您更改了要求:

对于cPanel的设置,你应该:
1)拆下傻基本的文件夹,什么是它的点呢?只是因为Yii的安装这种方式并不意味着你必须保持它。所以一切移动1级最高。
2)重命名网页到public_html确保你在一些文件重新命名它太(配置/引导想到)。

For a cpanel setup you should:
1) remove the silly basic folder, what is the point of it anyway? Just because Yii installs that way does not mean you have to keep it. So move everything 1 level up.
2) Rename web to public_html make sure you rename it in some files too (config/bootstrap comes to mind).

是的,你可以使用的.htaccess做,但你不应该有这些文件暴露给互联网的,只是你的Web文件夹应该被暴露,所以我不会给你的解决方案,因为它不是一个很好的一个。

Yes you can do it with .htaccess but you should not have the files exposed to the internet, just your web folder should be exposed so I am not giving you that solution because it is not a good one.

这篇关于Yii的2.0隐藏/基本/从URL网页一起的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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