This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
Helicon Ape
 Helicon Tech : Helicon Ape
Subject Topic: Reverse Proxy - Fixing Relative Links Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
reach4thelasers
Newbie
Newbie


Joined: 30 July 2011
Online Status: Offline
Posts: 4
Posted: 31 July 2011 at 12:04am | IP Logged Quote reach4thelasers

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 View reach4thelasers's Profile Search for other posts by reach4thelasers
 
reach4thelasers
Newbie
Newbie


Joined: 30 July 2011
Online Status: Offline
Posts: 4
Posted: 31 July 2011 at 5:44am | IP Logged Quote reach4thelasers

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 View reach4thelasers's Profile Search for other posts by reach4thelasers
 
reach4thelasers
Newbie
Newbie


Joined: 30 July 2011
Online Status: Offline
Posts: 4
Posted: 31 July 2011 at 6:28am | IP Logged Quote reach4thelasers

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 View reach4thelasers's Profile Search for other posts by reach4thelasers
 
Vyacheslav
Admin Group
Admin Group


Joined: 02 July 2008
Location: Ukraine
Online Status: Offline
Posts: 1542
Posted: 01 August 2011 at 4:06am | IP Logged Quote Vyacheslav

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 View Vyacheslav's Profile Search for other posts by Vyacheslav Visit Vyacheslav's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum