Forum Moderators: phranque

Message Too Old, No Replies

Should be easy?! mod rewrite 1 domain to another!

         

lightsout

10:54 pm on Jul 31, 2006 (gmt 0)

10+ Year Member



Hello,

I cannot, for the life of me, find a solution to waht I need to do, so ANY help is greatly appreciated here.

Using .htaccess, I would like to REWRITE all URLs in my site from...

media.site1.com

TO

media.site2.com

Like I said, any help is GREATLY appreciated!

jdMorgan

11:04 pm on Jul 31, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You don't need mod_rewrite for this, just a simple mod_alias RedirectPermanent [httpd.apache.org] directive:

RedirectPermanent / http://www.example.com/

Replace example.com with your actual new domain name.

Jim

lightsout

12:00 am on Aug 1, 2006 (gmt 0)

10+ Year Member



hmmm....

Ok, this will, in the content of my pages, make...

media.server1.com

look like...

media.server2.com

...?

I'm not truly looking to redirect, I'm looking to "rewrite" these URLs in my content pages. Thanks for your help so far!

jdMorgan

12:13 am on Aug 1, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh. If you want to change the links on your pages, you'll need to edit your pages.

Mod_rewrite and mod_alias work during the URL-to-filename translation phase of the Apache API. That is, they work after an HTTP request is recieved by the server, but before any content is served or any scripts are activated. Therefore, they have no effect on the 'content' of your pages.

mod_rewrite can change the URL by redirecting a request -- that is, by sending a response back to the browser that says, "That content has moved, ask for it again at this new URL" -- or it can rewrite a URL (change the server filepath associated with a URL), but it cannot change the URL 'seen' on your pages -- after all, the old link has alreay been 'seen' and has been clicked-on, so it's too late...

Apache 2 supports some output filters, but they're an inefficient way to do what you want.

Jim