RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} (DataForSeoBot|MJ12bot|AhrefsBot|AwarioBot|BLEXBot|dotbot|PetalBot|SemrushBot*|SiteAuditBot|SplitSignalBot|Yandex) [NC]
RewriteRule (.*) - [F,L]
RewriteCond %{HTTP_USER_AGENT} (Pocket Casts|PocketCasts) [NC] # Target specific user-agent (replace with actual string)
RewriteRule ^site_total_([^_]+)_rss\.php$ /site_$1_rss.php [L,R=301]
RewriteRule "^comments_rss.php$" "/comments.rss" [R]
RewriteRule "^live$" "https://stream.lugcast.mywire.org/stream" [R=301,NE,L]
RewriteRule "^maillist$" "https://lists.hackerpublicradio.com/mailman/listinfo/hpr" [R=301,NE,L]
RewriteRule "^download.php" "/syndication.html" [R=301,NE,L]
RewriteRule "^about.php|^help_out.php" "/about.html" [R=301,NE,L]
RewriteRule "^recording.php" "/about.html#recording_a_podcast" [R=301,NE,L]
RewriteRule "^stuff_you_need_to_know.php" "/about.html#agreement" [R=301,NE,L]
RewriteRule "^contribute.php" "/about.html#so_you_want_to_record_a_podcast" [R=301,NE,L]
RewriteRule "^requested_topics.php" "/about.html#requested_topics" [R=301,NE,L]
RewriteRule "^comments_viewer.php" "/comments_viewer.html" [R=301,NE,L]
RewriteRule "^sitemap.php|^sitemap.txt" "/sitemap.html" [R=301,NE,L]
RewriteRule "^tags.php" "/tags.html" [R=301,NE,L]
RewriteRule "^correspondents.php" "/correspondents/index.html" [R=301,NE,L]
RewriteRule "^index_full.php|^show.php|^index.php|^twat.php" "/eps/index.html" [R=301,NE,L]
RewriteRule "hosts/ken_fallon" "https://hackerpublicradio.org/correspondents/0030.html" [R=301,NE,L]
RewriteRule "^calendar.php$" "http://hub.hackerpublicradio.org/calendar.php" [R,L]
ErrorDocument 404 /404.shtml
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^facebook$ "https\:\/\/www\.facebook\.com\/home\.php\?sk\=group_130169220378872\¬if_t\=group_r2j" [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^linkedin$ "http\:\/\/www\.linkedin\.com\/groups\/Hacker\-Public\-Radio\-3737302" [R=301,L]
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^itunes$ "http\:\/\/itunes\.apple\.com\/us\/podcast\/hacker\-public\-radio\/id281699640" [R=301,L]
# Anti Spam
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^eps/eps/(.*)$ http://localhost/ [R=301,L]
RewriteRule index.php/eps/eps/(.*)$ http://localhost/ [R=302,L]
# Remove facebook tracking
RewriteCond %{QUERY_STRING} ^(.*)(?:^|&)fbclid=(?:[^&]*)((?:&|$).*)$ [NC]
RewriteCond %1%2 (^|&)([^&].*|$)
RewriteRule ^(.*) /$1?%2 [R=301,L]
# Redirect episodes to archive.org
RewriteRule "eps/hpr([0-9]{4})\.(ogg|mp3|spx|wav|flac|opus)" "https://archive.org/download/hpr$1/hpr$1.$2"
RewriteRule "local/hpr([0-9]{4})\.(ogg|mp3|spx|wav|flac|opus)" "https://archive.org/download/hpr$1/hpr$1.$2" [R=301,L]
# Rewrite the host series and episode pages
RewriteCond %{QUERY_STRING} id=(\d{1})$
RewriteRule series\.php /series/000%1.html [L]
RewriteCond %{QUERY_STRING} id=(\d{2})$
RewriteRule series\.php /series/00%1.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{3})$
RewriteRule series\.php /series/0%1.html? [L]
RewriteRule "^series\.php$" "/series/index.html" [R=301,NE,L]
RewriteCond %{QUERY_STRING} id=(\d{1})$
RewriteRule hosts\.php /correspondents/000%1.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{2})$
RewriteRule hosts\.php /correspondents/00%1.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{3})$
RewriteRule hosts\.php /correspondents/0%1.html? [L]
RewriteRule "^hosts\.php$" "/correspondents/index.html?" [L]
RewriteCond %{QUERY_STRING} id=(\d{1})$
RewriteRule eps\.php /eps/hpr000%1/index.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{2})$
RewriteRule eps\.php /eps/hpr00%1/index.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{3})$
RewriteRule eps\.php /eps/hpr0%1/index.html? [L]
RewriteCond %{QUERY_STRING} id=(\d{4})$
RewriteRule eps\.php /eps/hpr%1/index.html? [L]
#RewriteCond %{QUERY_STRING} (.*(?:^|&))id=([^&]*)&?(.*)&?$
#RewriteRule "eps\.php" "/eps/hpr%2/index.html?" [L]
RewriteRule "^eps\.php$" "/eps/index.html" [R=301,L]
RewriteCond %{QUERY_STRING} series=111
RewriteRule hpr_mp3_rss\.php https://linuxinlaws.eu/inlaws_rss.xml
Order Allow,Deny
Allow from all
header set X-Clacks-Overhead "GNU Terry Pratchett"
Order Allow,Deny
Deny from x.x.x.x
Allow from all