This forum has been moved here:
Helicon Tech Community Forum

Helicon Ape (Forum Locked Forum Locked)
 Helicon Tech : Helicon Ape
Subject Topic: Reverse Proxy - Fixing Relative Links
Author
Message |
reach4thelasers
Newbie


Joined: 30 July 2011
Posts: 4
Posted: 31 July 2011 at 12:04am

I've successfully set up a reverse proxy that proxies
http://mydomain.com/admin to http://admin.mydomain.com it
works fine.

Now the relative links in the pages need to be corrected.
href="/" should be href="/admin"
href="/home/index" should be href="/admin/home/index"

I'm using mod_replace to change the links in the page.
The following works fine, but it only changes the link on
the first matched item on the page and leaves the rest
untouched. How do I make it change all the links, not
just the first?

ReplaceFilterDefine revproxy CaseIgnore
ReplacePattern revproxy href="(/.*)" href="/admin\1"
SetEnv mod_replace revproxy
Back to Top
 
reach4thelasers
Newbie


Joined: 30 July 2011
Posts: 4
Posted: 31 July 2011 at 5:44am

I am still trying to work this out. Its causing me a huge
headache. I think it might have something to do with the
quotes in the regex - which are valid characters for use in
a regular expression (no escaping required) but also seem
to be used by the mod_replace parser for delimiting strings
according to the examples on the mod_replace page.

The weird thing is ReplacePatter revproxy the foo
changes every instance of the word this, to foo. But for
some reason my regex above only works on the first match.
Back to Top
 
reach4thelasers
Newbie


Joined: 30 July 2011
Posts: 4
Posted: 31 July 2011 at 6:28am

Can't say I'm terribly happy with this, seems a bit of a
hacky regex, but it works:


ReplaceFilterDefine revproxy CaseIgnore
ReplacePattern revproxy 'href="/' 'href="/admin/'
SetEnv mod_replace revproxy

So it looks like the problem was the .* - why would this
only match the first item?
Back to Top
 
Vyacheslav
Admin Group


Joined: 02 July 2008
Location: Ukraine
Posts: 1542
Posted: 01 August 2011 at 4:06am

Hello.
Please try to use mod_seo instead:

Code:
SetEnv mod_seo
SeoRule ^(?!admin)(/.*)$ /admin$1 [NC,Scope=A]


or the following code for mod_replace:
Code:
ReplaceFilterDefine revproxy CaseIgnore
ReplacePattern revproxy 'href="(/[^\s]*?)"' 'href="/admin\1"'
SetEnv mod_replace revproxy


__________________
Slavik Shynkarenko,
Helicon Tech.
Back to Top Visit Vyacheslav's Homepage
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version