homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

301 mp3 to homepage

 3:56 pm on May 23, 2014 (gmt 0)


my site has an mp3 located at www.example.com/audio/song.mp3
This happens to have a lot of backlinks and I want to redirect it to my homepage.

Is this code valid:

RewriteEngine On
# Redirect non-www to www:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^.*/index\.html
RewriteRule ^(.*)index.html$ /$1 [R=301,L]

Redirect 301 /audio/song.mp3 http://www.example.com



 4:31 pm on May 23, 2014 (gmt 0)

Hello unclej, your question makes me ask if these are backlinks or hotlinks that you want to redirect? It is a media file, not a page.

Before you get to that part, you should take a look at the rest of the htaccess rules you have in place and reverse the order of those first two rules so the server doesn't need to loop twice for one request. That rule in #1 position doesn't look quite right.


 5:47 pm on May 23, 2014 (gmt 0)

not sure what a hotlink is...but a lot of websites directly linked to the mp3. Now the mp3 no longer exists and I want to redirect all the link juice to the homepage.


 7:20 pm on May 23, 2014 (gmt 0)

A hotlink is you hosting a resource (like an image or an MP3) that is used as a resource on another site. I am not sure that hotlinked resources carry any link juice, it does not seem that they could since they are not standalone pages that get a slot in the serps. The links were not backlinks beneficial to your site, it was other sites running up your bandwidth usage. If you have removed the file you should return a 404. A 301 redirect tells search engines that what used to be "here" is now over "there" and that isn't what they'll find. Google considers that a soft 404, not a good thing. 404s are natural and normal, soft 404s aren't.


 7:30 pm on May 23, 2014 (gmt 0)

Is this code valid:

NEVER combine mod_rewrite and mod_alias in the same htaccess. All the mod_alias rules (Redirect by that name) will execute after the RewriteRules, here meaning after your domain-name and index.html redirects-- which, incidentally, are in the wrong order. Hostname is the very last redirect; index.html is typically the second-to-last.

not sure what a hotlink is...but a lot of websites directly linked to the mp3.

I'm not sure the term "hotlink" applies to an mp3, unless other people's sites are coded to start playing your sounds automatically. We're talking about music files, right?

Mass redirects of nonexistent files to the home page are almost never appropriate. Who cares what the home page is? They wanted music. You can choose to serve a 410, or let it default to 404. Either way, make a nice custom 404/410 page to let your users know what's up.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved