Jump to content

Redirecting from a subfolder to a subdomain


HaLo2FrEeEk

Recommended Posts

Hey, I moved all the files from a certain folder on my main domain, to a new subdomain.  Unfortunately since the site's been in operation for 3 years now there are plenty of links around the web that point to the old location.  I wanted to set up an .htaccess file that would take all requests for files in the folder and send them to the subdomain, where all the files will be moved to.  I had it working with a subfolder test, but when I tried to change it a little I couldn't get it to work how I needed it.  Basically the old folder was called /movies, and the new subdomain is media.infectionist.com.  If, for example, there is a link to the file testvid.wmv that points to the /movies folder, I want it to automatically redirect to media.infectionist.com/testvid.wmv.  I also have a subfolder in the movies folder that I want to go to a different subdomain than the other files are going to, I want this subfolder, /cutscenes, to go to cutscenes.infectionist.com instead.  Here is the .htaccess I have so far:

 

RewriteEngine on
RewriteRule cutscenes/(.*)\.(wmv|mp4|mov|png|jpg) http://cutscenes.infectionist.com/$1\.$2
RewriteRule (.*)\.(wmv|mp4|mov|png|jpg|scr|exe) http://media.infectionist.com/$1\.$2

 

So any request that tries to get a file inside the /cutscenes folder should be directed to cutscenes.infectionist.com, and any other request should go to media.infectionist.com, right?  Well, it's not working.  Since I've already deleted the files from the /cutscenes folder, they're just giving a 404 error.  When I try to call a file from the regular /movies folder, it just plays it from that folder and doesn't redirect to the media subdomain.  Why is this happening?  I thought I had it in the right order, but it shouldn't matter because either way I have it it still doesn't work.

 

Can someone PLEASE help me figure this out!  I really want to clean up my movies folder.  In fact it'd be perfect if I could just delete the movies folder alltogether and have this .htaccess reside in the root of my main domain.

 

Thank you all in advance.

 

Edit: if I remove the RewriteRule (.*)\.(wmv|mp4|mov|png|jpg|scr|exe) http://media.infectionist.com/$1\.$2 line from the .htaccess then the cutscene redirect works...but not the other movies.  If I remove the RewriteRule cutscenes/(.*)\.(wmv|mp4|mov|png|jpg) http://cutscenes.infectionist.com/$1\.$2 line then the media redirect works, but not cutscenes.  Is there a way to get them to work together?!?  The only thing I can think of is to have this .htaccess redirect all requests to media, then have another htaccess in the media subdomain that redirects cutscene requests to the cutscene subdomain, but that seems like it would be overkill.  Is that what I have to do?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.