0

I've an apache reverse proxy and i try to make a rules for redirects few urls of example2 to example1 but my rewrite rules doesn't work.

I've try this in the vhost of example2 :

ProxyPass / https://example1.com/index2.html
ProxyPassMatch ^[A-Za-z0-9]$ https://example1.com/news-$1

The first rule work but not the second with ProxyPassMatch, when i go to https://example2.com/1test05 that return me a 404 Error but direct access to https://example1.com/news-1test05 work.

Any idea?

3

Because you regex doesn't match.

^[A-Za-z0-9]$ matches URIs composed of one alphanumeric character and you didn't put any leading slash nor capture group.

You need ProxyPassMatch ^/([A-Za-z0-9]+)$ https://example1.com/news-$1 instead.

6
  • You are right about the slash, but the line ProxyPass / example1.com/index2.html prevents the second rule to work properly, I need a rule to set a homepage without breaking the the second rule, I've test few rules with mod_proxy and mod_rewrite but I can't find the right rule. – Olaf Mar 22 '15 at 16:44
  • @Olaf Swap both rules ? ^/[A-Za-z0-9]+$ doesn't match /, if that's what you mean. – Xavier Lucas Mar 22 '15 at 16:49
  • Yes I need a rule to set a homepage for example2.com pass through the proxy or not are no consequence for me maybe a DirectoryIndex index.html in vhost example2 work ? and I need a rule that redirects example2.com/1test05 to example1.com/news-1test05 and a rule that redirects example2.com/board/1test05 to example1.com/board/board-1test05 – Olaf Mar 22 '15 at 17:11
  • @Olaf You posted a question about a ProxyPassMatch rule not working, I answered. Now, you are trying to extend it to a complete different question and that's not how ServerFault works. One question, one issue. So things stay clear for readers and we don't get a whole bunch of comments below answers about things not related to the initial question. Ask another one if there's another thing you didn't mention that you can't manage to get working. – Xavier Lucas Mar 22 '15 at 17:16
  • Ok, thanks for your help, i ask a new question but I'm not sure it's necessary because the problem was my second rule doesn't work and now the second rule work but not the first rule because the two rules can't works together... so your solution is uncomplete. – Olaf Mar 22 '15 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.