Forum Moderators: phranque

Message Too Old, No Replies

Best approach to redirecting a subdomain

sub domain has been spun off to it's own url

         

travelin cat

6:22 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



We have an 11 year old subdomain on one of our sites that has been very successful and growing rapidly, it is at www.mydomain.com/music

We purchased a domain name that fits it perfectly and uploaded the site to it about two years ago and it is doing well, however the old subdomain at www.mydomain.com is also doing well but they have almost identical content and both make good $ in AdWords.

We want to eliminate the sub domain and point all of the interior pages to the new domain, my question is: what is the best way to do this? I have the ISP redirecting the subdomain, but this only affects requests coming to the root and none of the files are redirected.

Thanks in advance...

physics

7:59 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I know the best way to do it is to have a 301 redirect for every unique subdomain page to a corresponding unique page on the main domain.
You can implement this in several ways. Are you on IIS or Apache?

physics

8:00 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



p.s. You said subdomain but you wrote www.mydomain.com/music ... that's a directory Either way 301 redirecting every page is the way to go I think.

travelin cat

8:47 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



physics, thank you, I did indeed mean directory....

there are over 500 files, so a 301 for each... guess I have my work cut out for me.

thanks for the reply

travelin cat

10:50 pm on Mar 30, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



After trying to get a 301 to work using traditional .htaccess methods, I had to contact the ISP for help, they said that the only way to do this is via a script in the header of each page:

<script>
window.location='http://www.yournewpage.com';
</script>

This works and returns a 200 response, I am wondering if this will cause problems with the se's thinking I am trying to spam them. Any thoughts?

physics

1:32 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ugh that is not the same thing as a 301 and will do you no good with search engines. I wouldn't worry as much about looking like a spammer as them dropping the pages because they just see a script tag. What went wrong with .htaccess?

travelin cat

2:37 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



500 server error.

The support person said it would not work on their servers.....

physics

4:20 am on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post the first few lines of your .htaccess file here (substitute example.com for your domain name)? Maybe there's an error in it.
I wouldn't trust the support person too much if they advised that sort of redirect. That wouldn't even redirect me if I visited your site because I don't allow javascript from all sites.
If you absolutely can't do a 301, at least do a meta refresh:
<META HTTP-EQUIV=REFRESH CONTENT="0; URL=http://www.example.org/bar">

Web hosts generally aren't too helpful with this stuff but you may still be able to get it done.

More info:
refresh vs 301: [w3.org...]
.htaccess: [httpd.apache.org...]

travelin cat

5:03 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Physics,
Thanks again. I tried two different methods:

In the root this is what I added to .htaccess

redirect 301 /old/old.html [mysite.com...]

After the 500 server error I tried this:

RewriteEngine On
RedirectMatch permanent ^/old/old.html$ [mysite.com...]

same error...

physics

6:15 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:

RewriteEngine On
RewriteRule ^/old/old.html$ http://www.mysite.com/new.html [R=301,L]

Also, if the pages names will match on the new domain you might be able to get them all done at once with something like:


RewriteEngine On
RewriteRule ^/old/(.*)$ http://www.mysite.com/$1 [R=301,L]

Make sure you check your .htaccess file has UNIX line breaks instead of windows. Use a text editor that allows you to choose UNIX file type (like EditPlus) and make sure to set the file type as UNIX, or edit it from the command line with pico, vi, or emacs.

Finally, do you get an error on all pages of your site when that .htaccess is up or just the one in question?

travelin cat

6:26 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Once again, thanks!

I tried this only on one page - there are almost 500 pages so I didn't want to find out it did not work after hours of typing....

I will try this and let you know if it works.

Also, the page names are exactly the same in the new location.

travelin cat

6:44 pm on Mar 31, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



bummer... 500 internal server error. on both methods

I made sure to use unix line breaks....

guess it's time to change hosts. We have other sites where this is easily accomplished via the control panel, but this monolithic ISP that we have been with since 1995 is just pathetic in what they offer.

physics

10:12 pm on Apr 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes changing hosts seems like a good idea at this point. Make sure you don't have much down time (read some of the changing host posts here) and also make sure your new host allows you to use mod_rewrite.