[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] Jetty 9 Redirect from Root to Sub-Directory.
|
On 6/6/13 19:38, O. Olson wrote:
Thank you very much Alexei! Regex lookarounds are something
I have trouble with. Did you do this off
the top of your head?
Well, I tried it once before e-mailing, just to be sure that it works.
:) Lookarounds are not my cup of tea either, but with a bit of trial and
error...
It worked perfectly, but I am trying to figure out how to
debug this, so that I learn from all this.
My first
problem is that after getting your suggestion to work i.e. enabling
OPTIONS=rewrite
etc/jetty-rewrite.xml
in my start.ini and putting your suggestion into
jetty-rewrite.xml, I decided to comment out the new rule from
jetty-rewrite.xml. I have no other rules at this time, but I am running Solr on
this jetty instance. When I attempt to access / i.e. http://localhost:7070/ I get a 500 error, not
a 404 error that I expected and I get the following exception in my log file.
<...>
/
java.lang.NullPointerException
at
org.eclipse.jetty.rewrite.handler.RuleContainer.apply(RuleContainer.java:199)
at
<...>
Just to make sure, I restored jetty-rewrite.xml from the
original download and I still get this exception. However, if I disable i.e.
comment out the two lines mentioned above in the start.ini, then I correctly
get the expected 404. Why does this happen?
It's most likely because you don't have any rules left for your
RewriteHandler (i.o.w. you commented out the only "Call name='addRule'"
present in jetty-rewrite.xml, but left the creation of RewriteHandler),
so it gets a null pointer when it tries to apply them. I would guess
that that's intended behavior -- either disable rewrite handler
completely, or have some rules defined for it.
I also
attempted to modify your suggestion to make rewrite possible from http://localhost:7070/foo/bar to http://localhost:7070/solr/#/foo/bar (I’m just playing here). I tried the following:
<Call name="addRule">
<Arg>
<New
class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
<Set
name="regex">(^(?!/solr/#/).*)</Set>
<Set
name="replacement">/solr/#$1</Set>
</New>
</Arg>
</Call>
This did not work. Do I need to escape the # ? I didn’t
think # is a special character in regex.
Thank you for all the help.
O. O.
Uh, that one I don't really know. According to this:
http://www.regular-expressions.info/comments.html
hash sign _in some cases_ can be used to comment things, but that
doesn't seem to be the case here. I guess we'll need someone who knows
regexps better.
Good luck,
Alex-