Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

We have two servers, and some content was moved to our old server, but, there are still some links on the web to those old directories on our old server.

So, any page in www.mysite.com/Pages/page.html I need to rewrite/redirect to www.mysite2.com/Pages/page.html. So, if anyone accesses any files in the www.mysite.com/Pages directory they will get the URL rewritten to the older server which is www.mysite2.com.

Am I going about this the wrong way?

share|improve this question
    
You ask, "am I going about this the wrong way?" I don't know, how are you going about it? What have you tried? Is it working? What web server are you using? –  larsks Dec 16 '09 at 0:41
add comment

2 Answers

If you're using Apache, the mod_alias documentation will probably be helpful. This module provides the Redirect family of commands.

share|improve this answer
add comment

If you're rewriting everything under a particular directory, then you can use the Redirect directive:

# In httpd.conf for mysite.com
Redirect /Pages http://www.mysite2.com/Pages

That will preserve everything under /Pages and pass it to www.mysite2.com, i.e., www.mysite.com/Pages/foo.html will go to www.mysite2.com/Pages/foo.html.

If you are only rewriting specific files (you said "some content was moved to our old server"), then you'll have to do it on a file-by-file basis. You can use the same Redirect directive, or you can use mod_rewrite; I think Redirect will be simpler for this. Keep in mind that Apache processes Redirect and rewrite directives serially at run time, so if you have a lot of them, it's definitely going to impact performance.

share|improve this answer
    
That will only redirect /Pages to mysite2.com/Pages, not /Pages/foo.html. You need something like Redirect ^/Pages/(.*)$ http://www.mysite2.com/Pages/$1 Note also the start and end delimiters for the regex, so something like www.mysite.com/Pages.html won't match. –  Andy Shellam Feb 16 '10 at 13:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.