【问题标题】:apache rewrite rules for controller directory控制器目录的apache重写规则
【发布时间】:2011-08-12 20:25:16
【问题描述】:

我有控制器文件所在的控制器目录。

我想这样做

sitename.com/test.php

不是

sitename.com/controller/test.php

如何用apache重写规则?

【问题讨论】:

  • 那么你想要的是从一个请求到 sitename.com/controller/test.php 到 sitename.com/test.php?

标签: php apache model-view-controller mod-rewrite controller


【解决方案1】:

您需要在.htaccess 中查看mod_rewrite

在 .htaccess 中添加重写规则很简单。首先,通过将此行添加到您的 .htaccess 来激活 mod_rewrite:

RewriteEngine on
RewriteBase /

然后添加你的规则来重定向你的页面:

RewriteRule ^([^/]+)$ /controller/$1

【讨论】:

    猜你喜欢
    • 2014-04-25
    • 2012-05-26
    • 1970-01-01
    • 2018-07-06
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 2011-09-02
    相关资源
    最近更新 更多