Can anyone explain to me how to use Mod Rewrite in Apache 2 to do the following?
I want to rewrite any mention of 'servername' with 'differentservername'.
So basically, if the site has an absolute link http://servername/blah.jpg it should instead return http://differentservername/blah.jpg
You could use a redirect. I had to do a similar thing for our Apache server when we changed our domain name and it works how you describe.
Redirect permanent / http://differentservername/
That isn't any use to us - it is reverse proxied so the server is not internet facing.
I'm looking at ProxyHTMLURLMap at the moment, using mod_proxy_html.
I'll explain my issue further - on this site, rather than use relative urls in the CSS 'style' code, they've used full server domains - eg:
Rather than the more elegant way of doing it:
So, the way I was thinking I should do it would be:
But it doesn't seem to be rewriting...
ProxyPass / http://server/
ProxyHTMLURLMap http://server/ /
Would this work?
Redirect 301 http://servername/blah.jpg http://differentservername/blah.jpg
No. That wouldn't rewrite anything - it'd just redirect any requests to the server for http://servername to http://differentservername - but as I said, differentservername is not an internet facing server - it is being reverse proxied.
Originally Posted by Arthur
I got it working by changing some other settings instead. :)