0

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?

Zed Said
  • 717
  • 6
  • 14
  • 25
  • 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 00:41

2 Answers2

1

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

larsks
  • 43,623
  • 14
  • 121
  • 180
1

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.

  • 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