【发布时间】:2012-11-11 08:29:53
【问题描述】:
我知道有很多关于 htaccess 的问题,但我尝试了可以在 Google 和 StackOverFlow 上找到的不同代码,但都没有奏效。
我的根目录中有以下内容:
index.php
.htaccess (the one I am trying to write)
controllers
--index.php
--mycontroller.php
models
--mymodel.php
view
-index.php
--myview.php
(我正在使用 MAMP&Firefox 在本地主机上工作)
我拥有的是这个链接
localhost:8888/MySite/controllers/mycontroller.php
我想要的是
localhost:8888/MySite/mycontroller
当我手动输入 url 时,我希望它在我的 MVC 代码中被重定向到正确的控制器
我试过了:
RewriteEngine On
RewriteBase /
RewriteRule ^/(.*)$ /controllers/$1 [L]
当我转到 blabla/controllers/mycontroller.php 时它不会重定向,并且当我手动转到 blabla/mycontroller 时不明白我在问什么。
【问题讨论】:
标签: apache .htaccess redirect url-rewriting