.htaccess 重定向文件类型


.htaccess redirect file type

我有一些旧的.swf文件/网站链接,它们目前指向一个404 Not Found页面。我想知道是否有一种简单的方法,使用.htaccess(或您可能推荐的任何其他方法)将这些文件/链接重定向到我的网站主页http:www.mysite.com/home

示例链接:

http://www.mysite.com/folder/file.swf

http://www.mysite.com/file.swf

这应该有效:

RewriteEngine On
RewriteRule ^.*'.swf$ /home [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mysite'.com/(.*).swf$ [NC]
RewriteRule ^(.*)$ http://www.mysite.com [R=301,L]

如果你想将所有swf文件永久重定向到 www.mysite.com/home,你可以使用.htaccess文件来实现。

首先,您必须在 Apache 中启用mod_rewrite。

然后将以下内容添加到您的 .htaccess 文件中:

Options +FollowSymlinks
RewriteEngine on
Rewriterule ^mysite'.com/(.*).swf$ http://www'.mysite'.com/home [R=301,NC,L]