文件不存在时.htaccess重定向
因此,我使用 .htaccess 将旧网站页面重定向到新网站页面。我的文件中的典型规则如下所示:
Redirect 301 /faqs.php http://blueprintprep.com/classroom/faq
奇怪的是,当服务器上存在旧文件时它工作正常,但是当我删除该文件时,最终的 URL 实际上如下所示:
http://blueprintprep.com/classroom/faq?/faqs.php
蓝色是什么大火正在发生??
该文件由一堆这些规则组成,对于 CodeIgniter 来说是这样的:
重写引擎开启 重写库 / RewriteCond %{REQUEST_URI} ^系统。* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^应用程序。* 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]
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]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
mod_rewrite
来代替。无论文件是否存在,这都会起作用。
希望有帮助。
You can use
mod_rewrite
instead.This will work regardless if the file exists or not.
Hope that helps.