使用 IIRF 重定向到 PDF
我正在使用 IIRF 将某些 URL 重定向到特定的 PDF 文件。例如,对于URL /newsletter/2010/02
,我希望它重定向到/pdf/newsletters/Feb2010.pdf
。我不太擅长正则表达式,但我创建了以下规则:
RedirectRule ^/newsletter/2010/01 /pdf/newsletters/Newsletter012010.pdf [I,R=301]
它确实会重定向,但地址栏不会改变,并且在尝试保存文件时它希望另存为 01
而不是 Feb2010.pdf
。我认为我的用户不会足够聪明,能够在保存之前输入 PDF
扩展名,而且他们也不应该这样做。我能做些什么吗?
I'm using IIRF to redirect certain URLs to specific PDF files. For instance, for the URL /newsletter/2010/02
I'd like it to redirect to /pdf/newsletters/Feb2010.pdf
. I'm not too hot at regular expressions, but I created the following rule:
RedirectRule ^/newsletter/2010/01 /pdf/newsletters/Newsletter012010.pdf [I,R=301]
and it does redirect, but the address bar doesn't change, and when trying to save the file it wants to save as 01
instead of Feb2010.pdf
. I don't presume my users will be savvy enough to enter a PDF
extension before saving, and they shouldn't have to. Is there anything I can do about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
两个建议:
奇怪的是它要用01作为文件。奇怪。您确定浏览器正在发送新请求吗?使用Fiddler进行验证。重定向应该会导致浏览器地址栏始终得到更新。如果您收到 301,您将在 Fiddler 跟踪中非常清楚地看到它。
如果您没有看到预期的 301 ,是否有可能您之前在 ini 文件中使用了 RewriteRule ,并且浏览器缓存了结果,现在当您请求 /newsletter/2010/01 时,您得到的是缓存结果,而不是来自 IIRF 的重定向 URL?清除浏览器缓存并再次请求以进行测试。
我想清除浏览器缓存并重试会很容易,甚至不需要检查 Fiddler。
Two suggestions:
It's strange that it wants to use 01 as the file. Surprising. Are you sure the browser is sending a new request? Use Fiddler to verify. A redirect should result in the browser address bar getting updated, ALWAYS. If you get a 301 you will see it very clearly in the Fiddler trace.
If you don't see the expected 301, Is it possible that you previously used a RewriteRule in the ini file, and the browser cached the result, and now when you ask for /newsletter/2010/01 , you are getting the cached result, rather than the redirected URL from IIRF? Clear your browser cache and request it again, to test this.
I guess it would be easy to just clear the browser cache and re-try it, without even checking Fiddler.