0

is it possible to have a redirect for a specific URL. I mean the following.

Redirect to an other site. On this site there are images under http://www.examples/images

ProxyPass /content http://www.example/content
ProxyPassReverse /content http://www.example/content

But images are not loading, so I try to add.

ProxyPass /images http://www.example/images

But there are also images on the proxy under http://www.proxy.com/images where I try to redirect.

So it is possible to redirect the images just for the example.com site when they needed?

I hope somebdy understand what I mean :)

  • If I understand you correctly rather than a ProxyPass you need to use mod_rewrite. You can set a rewrite condition such that when the requested resource does not exist as a file a rewrite rule with a proxy target gets triggered. This answer might apply http://serverfault.com/a/656001/37681 – HBruijn Sep 12 '16 at 21:16

3 Answers3

1

Use the Redirectdirective in mod_alias, see the documentation here.

This should help you:

# Redirect to a URL on a different host
Redirect "/content" "http://www.example/content"
M. Glatki
  • 1,964
  • 1
  • 17
  • 33
  • Hi, the simple redirect is working, but when I type http://www.myproxy/content/test/, I get an redirect to http://www.example/content. – Charlie Piks Sep 13 '16 at 07:46
  • Is it maybe possible to use just the exact path? So when I type http://www.myproxy.com/content/ I want the redirect but when I type http://www.myproxy.com/content/test/test/test I do not want a redirect. – Charlie Piks Sep 13 '16 at 09:00
  • RedirectMatch will set you up. Please take a look at the documentation i linked before further inquiry. – M. Glatki Sep 13 '16 at 12:21
  • RedirectMatch "^/Images/(.*)" "http://new.example.com/Images/$1" I add this one for my images, but is doesnt work. What I am doing wrong. – Charlie Piks Sep 21 '16 at 19:13
0

If you want to link a specific URL pattern to another site, then this question has been answered here using mod_rewrite instead of ProxyPass : https://stackoverflow.com/a/1701992/1725739

MikaDo-
  • 61
  • 1
  • 3
  • 1
    Consider mod_alias with redirect instead. Also see https://httpd.apache.org/docs/2.4/rewrite/avoid.html – M. Glatki Sep 12 '16 at 23:09
0

I tried an other solution so far.

    RewriteEngine On
    RewriteCond %{REQUEST_URI} !myproxy.com/content/$ [NC]
    RewriteRule ^ htpp://www.example.de%{REQUEST_URI} [L,NE,P]

But everything is redirect to www.example.com How can I change this?