Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Quick mod_rewrite question

Options
  • 04-09-2004 1:50pm
    #1
    Registered Users Posts: 1,569 ✭✭✭


    Hi,

    I'm moving a load of pages from their own domain to a subdomain on another site. I want to send a http 301 status when someone requests the old file, with the correct location header for the file. I've written a php script that will do this, so when you type http://www.foo.com/redirect.php?url=bar.html you get a 301 which redirects to http://foo.new.com/bar.html. Now all I need is to set up mod rewrite so when someone tries to access http://www.foo.com/bar.html, it redirects them to the php script, which then sends them to the correct new location.

    Unfortunately, I know nothing about mod rewrite. I've tried googling, but all the results I got seemed a little over my head.

    This should be a fairly simple rule, right? Can anybody help me out with it?

    TIA


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Ah, mod_rewrite, the Apache module of the Gods. :)

    But in this case, unless you need to leave some content accessible in foo.com, I'm not sure why you need it. If all the pages/resources under foo.com are being redirected to foo.new.com, all you need is RedirectPermanent (or of course Redirect with a status):
    RedirectPermanent / http://foo.new.com/
    
    Now if sites are on the same server and you want to drop the foo.com VirtualHost altogether, that's another matter entirely, and we can go back to mod_rewrite (see the first bullet point in the flags section of RewriteRule).
    RewriteRule /(.*) http://foo.new.com/$1 [R=301]
    
    HTH,
    adam


  • Registered Users Posts: 1,569 ✭✭✭maxheadroom


    Thanks - that's a much simpler way to go about this :)


Advertisement