.htaccess redirect when file does not exist

So I'm using .htaccess to redirect old site pages to new site pages. A typical rule in my file looks like this:

Redirect 301 /faqs.php http://blueprintprep.com/classroom/faq

Strangely, it works fine when the old file exists on the server, but when I remove the file, the final URL actually looks like this:

http://blueprintprep.com/classroom/faq?/faqs.php

What in the blue blazes is going on??

The file is made up of a bunch of these rules and this for CodeIgniter:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteRule ^application_consulting/(.*) http://blueprintprep.com/oneonone/app_consulting [R=301,L]
RewriteRule ^weekend/(.*) http://blueprintprep.com/classroom [R=301,L]
RewriteRule ^workshop/(.*) http://blueprintprep.com/oneonone [R=301,L]


You can use mod_rewrite instead.

RewriteEngine on
RewriteRule ^/faqs.php$ /classroom/faq [L,R=301]

This will work regardless if the file exists or not.

Hope that helps.

链接地址: http://www.djcxy.com/p/36538.html

上一篇: 配置.htaccess条目

下一篇: .htaccess文件不存在时重定向