【发布时间】:2013-06-30 01:01:58
【问题描述】:
我正在将网站重组为 MVC 框架,并且正在将所有内容从根目录的根目录移动到有组织的文件结构中。因此,现在用户无需访问 domian.org/homeloans.php,而是需要访问 domain.org/loans/homeloans。这是我用来引导网站流量的 .htaccess 文件。
RewriteEngine on
DirectorySlash on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rt=$1 [L,QSA]
这不应该像添加一样简单吗:
Redirect 301 /homeloans.php https://domain.org/loans/homeloans
打开重写引擎后?但是,当我这样做时,我会在地址栏中看到它以及 404:https://domain.org/loans/homeloans?rt=homeloans.php
请指教。
【问题讨论】:
-
这很有道理...您将
?rt设置为捕获组的值,即homeloans.php。您的重写应该是index.php,然后您在 PHP 端确定要访问的资源。 -
在上面的代码中,您将 Redirect 拼写为“Recirect”。这个错字出现在您的 .htaccess 文件中,还是仅出现在此页面上?
-
@Arkanon 已修复,问题出在此页面上。
标签: php .htaccess redirect url-rewriting http-status-code-301