Mod_rewrite removing white spaces from outside url.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Mod_rewrite removing white spaces from outside url.

Wendell Hatcher
Hello, I have an issue where we have Apache 2.4.4.X using mod_proxy_balancer pointing at Apache Tomcat 8. Our applications returning an outside url that has space in the url i.e. (www.example.com/myapp/ structs/ somedata/ We want to return this url without spaces because it fails. I have tried Apache mod_rewrite and the regex below within my vhost.conf file as well as using it with the Apache tomcat rewrite module inside of a rewrite.conf file with no success.

I confirmed it was working atleast running by using the trace8 on my mod_rewrite loglevel. But, what it doesnt do is clean up the spaces in question.

# remove spaces from start or after /
RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]

# remove spaces from end or before /
RewriteRule ^(.+?)[\s%20]+(/.*|)$ $1$2 [L]

# replace spaces by - in between
RewriteRule ^([^\s%20]*)(?:\s|%20)+(.*)$ $1-$2 [L,R]
Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Eric Covener
> Our applications returning an outside url
In a redirect? In HTML?

> RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
If there is a literal %20 I don't think this should be in square
brackets.  I don't think the \s will ever match so I would drop it at
the same time.

> We want to return this url without spaces because it fails.

The rewrite rules don't change what's "returned" they modify the URL
requested on the server. Can you attach your rewrite:trace8 output
that fails to modify the URL w/ the improvements above?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Wendell Hatcher
Thankyou Eric! :) 

Eric, before  running I want to confirm that this will work below?
<VirtualHost *:80>


ProxyPreserveHost On

ProxyPass / http://X.X.X.X:8080/login

RewriteEngine On


RewriteRule ^(.*/|)+(%20)+(.+)$ $1$2 [L]

# remove spaces from end or before /
RewriteRule ^(.+?)+(%20)+(/.*|)$ $1$2 [L]

# replace spaces by - in between
RewriteRule ^(^%20*)+(?:%20)+(.*)$ $1-$2 [L,R]



ProxyPassReverse / http://X.X.X.X:8080/login

</VirtualHost>

On Sun, Jun 7, 2020 at 3:41 PM Eric Covener <[hidden email]> wrote:
> Our applications returning an outside url
In a redirect? In HTML?

> RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
If there is a literal %20 I don't think this should be in square
brackets.  I don't think the \s will ever match so I would drop it at
the same time.

> We want to return this url without spaces because it fails.

The rewrite rules don't change what's "returned" they modify the URL
requested on the server. Can you attach your rewrite:trace8 output
that fails to modify the URL w/ the improvements above?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Wendell Hatcher
In reply to this post by Eric Covener
Here are my logs as well.

Eric, 


71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] init rewrite engine with requested uri /
[Sun Jun 07 19:59:35.067175 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(.*/|)+(%20)+(.+)$' to uri '/'
[Sun Jun 07 19:59:35.067212 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(.+?)+(%20)+(/.*|)$' to uri '/'
[Sun Jun 07 19:59:35.067240 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(^%20*)+(?:%20)+(.*)$' to uri '/'
[Sun Jun 07 19:59:35.067249 2020] [rewrite:trace1] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] pass through /


On Sun, Jun 7, 2020 at 3:41 PM Eric Covener <[hidden email]> wrote:
> Our applications returning an outside url
In a redirect? In HTML?

> RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
If there is a literal %20 I don't think this should be in square
brackets.  I don't think the \s will ever match so I would drop it at
the same time.

> We want to return this url without spaces because it fails.

The rewrite rules don't change what's "returned" they modify the URL
requested on the server. Can you attach your rewrite:trace8 output
that fails to modify the URL w/ the improvements above?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Wendell Hatcher


Here are my logs as well.

Eric, 


71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] init rewrite engine with requested uri /
[Sun Jun 07 19:59:35.067175 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(.*/|)+(%20)+(.+)$' to uri '/'
[Sun Jun 07 19:59:35.067212 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(.+?)+(%20)+(/.*|)$' to uri '/'
[Sun Jun 07 19:59:35.067240 2020] [rewrite:trace3] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] applying pattern '^(^%20*)+(?:%20)+(.*)$' to uri '/'
[Sun Jun 07 19:59:35.067249 2020] [rewrite:trace1] [pid 5829:tid 140030530008832] mod_rewrite.c(470): [client 71.75.229.92:59917] 71.75.229.92 - - [<a href="http://13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial">13.56.11.156/sid#5646ee71d550][rid#7f5b5000ea70/initial] pass through /


On Sun, Jun 7, 2020 at 3:41 PM Eric Covener <[hidden email]> wrote:
> Our applications returning an outside url
In a redirect? In HTML?

> RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
If there is a literal %20 I don't think this should be in square
brackets.  I don't think the \s will ever match so I would drop it at
the same time.

> We want to return this url without spaces because it fails.

The rewrite rules don't change what's "returned" they modify the URL
requested on the server. Can you attach your rewrite:trace8 output
that fails to modify the URL w/ the improvements above?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Wendell Hatcher
In reply to this post by Wendell Hatcher


Thankyou Eric! :) 

Eric, before  running I want to confirm that this will work below?
<VirtualHost *:80>


ProxyPreserveHost On

ProxyPass / http://X.X.X.X:8080/login

RewriteEngine On


RewriteRule ^(.*/|)+(%20)+(.+)$ $1$2 [L]

# remove spaces from end or before /
RewriteRule ^(.+?)+(%20)+(/.*|)$ $1$2 [L]

# replace spaces by - in between
RewriteRule ^(^%20*)+(?:%20)+(.*)$ $1-$2 [L,R]



ProxyPassReverse / http://X.X.X.X:8080/login

</VirtualHost>

On Sun, Jun 7, 2020 at 3:41 PM Eric Covener <[hidden email]> wrote:
> Our applications returning an outside url
In a redirect? In HTML?

> RewriteRule ^(.*/|)[\s%20]+(.+)$ $1$2 [L]
If there is a literal %20 I don't think this should be in square
brackets.  I don't think the \s will ever match so I would drop it at
the same time.

> We want to return this url without spaces because it fails.

The rewrite rules don't change what's "returned" they modify the URL
requested on the server. Can you attach your rewrite:trace8 output
that fails to modify the URL w/ the improvements above?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Eric Covener
In reply to this post by Wendell Hatcher
On Sun, Jun 7, 2020 at 4:03 PM Wendell Hatcher
<[hidden email]> wrote:
>
> Thankyou Eric! :)
>
> Eric, before  running I want to confirm that this will work below?

Why guess?

> applying pattern '^(.*/|)+(%20)+(.+)$' to uri '/'

There's no spaces in the URL being requested. What could you rewrite?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Mod_rewrite removing white spaces from outside url.

Wendell Hatcher
You are correct the inbound doesn’t have spaces and the redirect returning does so there isn’t anything to rewrite on. Let me work with the development team on the returned values.

I appreciate the help and confirmation as well.

Wendell

> On Jun 7, 2020, at 5:00 PM, Eric Covener <[hidden email]> wrote:
>
> On Sun, Jun 7, 2020 at 4:03 PM Wendell Hatcher
> <[hidden email]> wrote:
>>
>> Thankyou Eric! :)
>>
>> Eric, before  running I want to confirm that this will work below?
>
> Why guess?
>
>> applying pattern '^(.*/|)+(%20)+(.+)$' to uri '/'
>
> There's no spaces in the URL being requested. What could you rewrite?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]