dongle0396 2013-07-02 15:15
浏览 23

PHP MVC和.htaccess 301重定向

I am restructuring a website to a MVC framework and am in the process of moving everything from root the root directory into an organized file structure. So now instead of going to domian.org/homeloans.php, the users will need to do domain.org/loans/homeloans. Here is the .htaccess file I use to direct website traffic.

RewriteEngine on
DirectorySlash on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA] 

Shouldn't this be as simple as adding:

Redirect 301 /homeloans.php https://domain.org/loans/homeloans 

after turning the rewrite engine on? However, when I do this, I get this in my address bar along with a 404: https://domain.org/loans/homeloans?rt=homeloans.php

Please advise.

  • 写回答

1条回答 默认 最新

  • douluyezhen4512 2013-07-02 15:19
    关注

    The problem seems to be not with the rewrite, but with the ability of your new MVC site to handle this URL. It looks like it can handle:

    /loans/homeloans
    

    but not

    /loans/homeloans?rt=homeloans.php
    

    Try accessing both directly; if the latter doesn't work but the former doesn't, then you know the issue is with the routing configuration of your MVC application.

    评论

报告相同问题?

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败