RE: java app URL rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, that makes sense that PT wouldn't apply and that the rewrite engine
won't reprocess the URL.

Hmmmmmmm.  I did a poor job of explaining what I'm trying to do.
Basically I'm trying to hide the "jahia/Jahia" portion of the URL.  That
means there are three cases that need to be handled:

1) If the incoming URL is http://portal-dev:81/, it needs to be directed
to the home page which is
http://portal-dev:81/jahia/Jahia/site/jazzd/pid/9.  But the outgoing URL
displayed in the user's browser needs to be
http://portal-dev:81/site/jazzd/pid/9.
Or
2) If the incoming URL is something like
http://portal-dev:81/jahia/Jahia/site/jazzd/pid/31, it needs to be
directed to http://portal-dev:81/jahia/Jahia/site/jazzd/pid/31.  But the
outgoing URL display in the user's browser needs to be
http://portal-dev:81/site/jazzd/pid/31.
Or
3) If the incoming URL is something like
http://portal-dev:81/site/jazzd/pid/17, it needs to be directed to
http://portal-dev:81/jahia/Jahia/site/jazzd/pid/17.  But the outgoing
URL display in the user's browser needs to be
http://portal-dev:81/site/jazzd/pid/17.


Just sticking to case 1) for now, the following redirects
http://portal-dev:81/ to
http://portal-dev:81/jahia/Jahia/site/jazzd/pid/9.  But the outgoing URL
displayed in the user's browser is
http://portal-dev:81/jahia/Jahia/site/jazzd/pid/9, not
http://portal-dev:81/site/jazzd/pid/9.  How do I modify the following to
redirect to the right place and not show "jahia/Jahia" portion in the
users browser?

<VirtualHost portal-dev.dande.com:81>
  RewriteEngine On
  RewriteLogLevel 3
  RewriteLog logs/rewrite_port81.log
  RewriteRule ^/$ jahia/Jahia/site/jazzd/pid/9 [R,L]
</VirtualHost>




Bob Stauffer
DBA
D&E Communications
Ephrata, PA
rstauffer@xxxxxxxxxxxxxxxxxxxx
717-738-8737 
-----Original Message-----
From: Justin Pasher [mailto:justinp@xxxxxxxxxxxxxxxxxxx] 
Sent: Thursday, September 18, 2008 13:53
To: users@xxxxxxxxxxxxxxxx
Subject: Re:  java app URL rewrite

Stauffer, Robert G wrote:
> Justin,
>
> Just tried:
> <VirtualHost portal-dev.dande.com:81>
>   RewriteEngine On
>   RewriteLogLevel 3
>   RewriteLog logs/rewrite_port81.log
>   RewriteRule ^/$ /jahia/Jahia/site/jazzd/pid/9 [C,PT]
>   RewriteRule ^/jahia/Jahia/(.+)$ $1 [L]
> </VirtualHost>
>
> Same thing happened: It serves up the correct page, but the browser
URL
> is http://portal-dev:81/ instead of
> http://portal-dev:81/site/jazzd/pid/9.  And the second RewriteRule is
> ignored:
>
> logs/rewrite_port81.log:
> 10.208.4.137 - - [18/Sep/2008:13:28:17 --0400]
> [portal-dev/sid#8122b18][rid#81c5c40/initial] (2) init rewrite engine
> with requested uri /
> 10.208.4.137 - - [18/Sep/2008:13:28:17 --0400]
> [portal-dev/sid#8122b18][rid#81c5c40/initial] (3) applying pattern
'^/$'
> to uri '/'
> 10.208.4.137 - - [18/Sep/2008:13:28:17 --0400]
> [portal-dev/sid#8122b18][rid#81c5c40/initial] (2) rewrite / ->
> /jahia/Jahia/site/jazzd/pid/9
> 10.208.4.137 - - [18/Sep/2008:13:28:17 --0400]
> [portal-dev/sid#8122b18][rid#81c5c40/initial] (2) forcing
> '/jahia/Jahia/site/jazzd/pid/9' to get passed through to next API
> URI-to-filename handler
> 10.208.4.137 - - [18/Sep/2008:13:28:17 --0400]
> [portal-dev/sid#8122b18][rid#81f7c18/initial] (2) init rewrite engine
> with requested uri /jazzdassets/scripts/tabber.js
> ...
>
> Anyone know if there's a way to force the redirect to the first
> RewriteRule output and display the output of the second RewriteRule?
>   

I don't think the [PT] flag will actually apply to RewriteRule 
directives (the documentation isn't 100% clear on the subject, but it 
says "... hack to enable post-processing of the output of |RewriteRule| 
directives, using |Alias|, |ScriptAlias|, |Redirect|, and other 
directives from various URI-to-filename translators"). I would think it 
would specifically mention RewriteRule in the list if that applied.

You may be getting hit by the way rewrite rules are applied. I think 
when the RewriteRules are inside the apache config as opposed to and 
.htaccess file, the rules are not "reprocessed" for a single request 
after matching a rewrite rule. This means it matches the first request, 
then doesn't attempts to reprocess the URL through additional 
RewriteRules. It seems like you could simplify the rule and avoid the 
chain altogether by just doing this:

RewriteRule ^/$ /site/jazzd/pid/9 [L]

If you go directly to "http://portal-dev:81/jahia/Jahia/something";, are 
you redirected to "http://portal-dev:81/something";? Since you are not 
setting a RewriteBase, you might need to tell mod_rewrite to anchor it 
to the beginning of the URL, like this:

RewriteRule ^/jahia/Jahia/(.+)$ /$1 [L]

To simplify things, I would first work on getting this rule to work by 
itself (which seems like it should with the change above). Then 
additional rules can be added.

-- 
Justin Pasher

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


**DISCLAIMER
This e-mail message and any files transmitted with it are intended for the use of the individual or entity to which they are addressed and may contain information that is privileged, proprietary and confidential. If you are not the intended recipient, you may not use, copy or disclose to anyone the message or any information contained in the message. If you have received this communication in error, please notify the sender and delete this e-mail message. The contents do not represent the opinion of D&E except to the extent that it relates to their official business.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux