MVC模式-仅在URL中显示控制器名称(隐藏index.php和操作)

时间:2019-01-06 01:37:07

标签: php .htaccess url model-view-controller

我正在使用Aruba提供的Hosting Linux服务来运行我的网站。

此刻,我的网站URL设计如下:

<The Champion's Name>

我想隐藏Running command lol:currgame. champName before return: This should never print champName inside fn: Brand champName before return: This should never print champName inside fn: Graves champName before return: This should never print champName inside fn: Tristana champName before return: This should never print champName inside fn: Jax champName before return: This should never print champName inside fn: Malzahar champName before return: This should never print champName inside fn: Thresh champName before return: This should never print champName inside fn: Galio champName before return: This should never print champName inside fn: Kai'Sa champName before return: This should never print champName inside fn: Trundle champName before return: This should never print champName inside fn: KennenRunning command lol:currgame. champName before return: Brand champName inside fn: Brand champName before return: Graves champName inside fn: Graves champName before return: Tristana ...参数,所以我的uri看起来像这样:

mysite.it/index.php?controller=&action=

我的基本文件夹结构是:

index.php

有解决方案吗?

,我需要保留原始的action,因为例如在某些mysite.it/controller 中,有一些函数在其中搜索www.mysite.it/ config/ controller/ lib/ model/ template/ .htaccess index.php 参数document.URL

谢谢。

1 个答案:

答案 0 :(得分:0)

您可以在.htaccess文件中包含以下文本
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

请记住,重写引擎必须在您的Web服务器配置中处于活动状态。