301 redirect all urls containing a certain phrase
I want to redirect all urls that contain "videoplayer.swf" in them. A load of pages got generated automatically with this and I want to 30开发者_StackOverflow中文版1 them all to the homepage.
<?php
if (preg_match ("videoplayer\.swf", $_SERVER['REQUEST_URI')) {
header (...);
exit;
}
?>
Or, if you're using apache, here's a .htaccess:
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://www\.example\.com/.*$ [NC]
RewriteRule ^.*videoplayer\.swf.*$ http://www\.example\.com/ [R,NC]
Based on checking the referrer, so you can have something like that viewable, if accessed from your site.
精彩评论