【问题标题】:Redirecting a download file to the new named file via htaccess通过 htaccess 将下载文件重定向到新的命名文件
【发布时间】:2015-05-21 20:40:31
【问题描述】:

随着时间的推移,我们软件的文件名因各种原因发生了变化,因此共享软件站点指向的旧下载文件不再存在。

我想重定向,以便如果有人单击指向旧文件的链接,他们可以下载新的(不同名称的)版本。

所以我尝试在 public_html 中添加一个 .htaccess 文件,其中包含以下内容(仅此而已):

Redirect 301 mydomain.com/oldinstaller.exe mydomain.com/newinstaller.exe

但这不起作用,我收到服务器发出的 500 错误。所有文件都在 public_html 中,.htaccess 文件也是如此。任何想法我做错了什么?

更新

我尝试了以下方法:

Options +FollowSymLinks
RewriteEngine On
RewriteRule ^oldinstaller.msi /newinstaller.exe [R=301,L]

浏览器会得到这个 URL:

https://example.com/home/admin/web/example.com/public_html/newinstaller.exe

如果我尝试:

RewriteRule ^oldinstaller.msi$ example.com/newinstaller.exe [R=301,L]

我明白了:

https://example.com/example.com/newinstaller.exe

【问题讨论】:

    标签: php apache .htaccess mod-rewrite redirect


    【解决方案1】:

    尝试使用 mod_rewrite 重定向

    RewriteRule ^oldinstaller.exe /newinstaller.exe [R=301,L]
    

    或通过在您的 php 页面中添加 HTTP 标头来重定向

    【讨论】:

    【解决方案2】:

    这应该是一个技巧:

    文件名:.htaccess

    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^oldinstaller.exe$ mydomain.com/newinstaller.exe [R=301,L]
    

    【讨论】:

    • 感谢您的帮助,但不高兴,请参阅更新后的问题
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 2012-07-29
    • 2017-10-12
    • 2011-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多