Redirections for two subdomains

New to mod_rewrite? This is a good place to start.

Redirections for two subdomains

Postby hd-J » Mon Sep 21, 2009 12:09 pm

Hi!

After hours of search on Google, I found your forum, and I hope you will be able to help me!

I am getting a headache over this situation:

Here are my domains and what I'd like to do wth them:

- website.com - redirect to blog.website.com
- www.website.com - redirect to blog.website.com
- blog.website.com
- movies.website.com

All subdomains have been created properly, I can reach the domain, and here is the situation so far:

My root folder (reachable with www.website.com and website.com) is composed of two things :
- a .htaccess file,
- The folder /movies/ containing all files for movies.website.com

All files for blog.website.com are on another server, and I started by adding a simple line to my .htaccess file:
Code: Select all
redirect 301 / http://blog.website.com/


Then the problem comes: even if I add another line such as
Code: Select all
redirect 301 /movies http://movies.website.com/

I am not able to reach movies.website.com

Whatever I do, I am redirected to blog.website.com. If I delete the .htaccess, everything runs properly and I have access to all domains.

So how can I do to have this redirection working properly?

Thanks for your help!
hd-J
 
Posts: 2
Joined: Mon Sep 21, 2009 11:53 am

Postby richardk » Tue Sep 22, 2009 9:22 am

What happens if you put the more specific redirects first?
Code: Select all
Redirect 301 /movies http://movies.example.com/
Redirect 301 /       http://blog.example.com/


If not, try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^movies(/(.*))?$ http://movies.example.com/$2 [R=301,L]

RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
RewriteRule ^(.*)$ http://blog.example.com/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby hd-J » Tue Sep 22, 2009 12:28 pm

I have tried to change the order, but it did not work!

I will give a try to your second method though, and I will come back to tell you if it worked!

Thank you for your help!
hd-J
 
Posts: 2
Joined: Mon Sep 21, 2009 11:53 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 20 guests

cron