Welcome to WebmasterWorld Guest from 54.224.5.186

Forum Moderators: Ocean10000 & incrediBILL & phranque

Apache rewrite rules help

     
3:04 am on May 4, 2017 (gmt 0)

New User

joined:May 4, 2017
posts:6
votes: 0


Hi, I need some help on apache rewrite rules, and requesting your help.

I have an application which works good on apache port 8020 which pulls the reports (runs on weblogic) successfully. Some of the reports have spaces and some of them have underscores.

We have an iptable rule which forwards the requests from 443 to 8020 on os level and the normal requests (with out these reports) coming to 443 work fine.
But I am having an issue pulling the reports from 443 from apache level.

So, for example I can't pull the reports with spaces

https://test-example.com/reports/saw.dll?capublisherEntry&Action=open&itemType=.xdo&bipPath=%2FPublic%2FTMF%2FUtilization%2FPrimary%20Utilization%20Report.xdo&path=%2Fshared%2FPublic%2FTMF%2FUtilization%2FPrimary%20Utilization%20Report.xdo


%20 are spaces.

Another URL with out spaces:

https://test-example.com/reports/saw.dll?capublisherEntry&Action=open&itemType=.xdo&bipPath=%2FPublic%2FTMF%2FUtilization%2FPrimary_Utilization_Report.xdo&path=%2Fshared%2FPublic%2FTMF%2FUtilization%2FPrimary_Utilization_Report.xdo


So the above two url's work on port 8020.

Is there any way that I can create a redirect cond or rule to make this work if the users are coming on port 443?

Thanks in advance.


[edited by: not2easy at 4:32 am (utc) on May 4, 2017]
[edit reason] readability [/edit]

3:23 am on May 4, 2017 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:8289
votes: 331


Hi m050317b and welcome to WebmasterWorld [webmasterworld.com]
6:07 am on May 4, 2017 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:10846
votes: 61


welcome to WebmasterWorld, m050317b!

help us better understand your requirements.
do you want to externally redirect any requests on port 443 for /reports/ urls paths to port 8020?
or is it more specific than that?
7:24 am on May 4, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13674
votes: 439


When these requests meet your config file, are the spaces %20 or are they spaces?

What Apache version are you on?

Do you have existing rules that work on the space-less strings, but not on the ones with spaces?
11:38 am on May 4, 2017 (gmt 0)

New User

joined:May 4, 2017
posts:6
votes: 0


@Lucy24 +, Thanks for the response.Yes they are spaces. Apache version is 2.2.
11:42 am on May 4, 2017 (gmt 0)

New User

joined:May 4, 2017
posts:6
votes: 0


@ Phranque, Thanks for the response. I already have a port redirect from 443 to 8443 on my linux server. What I am puzzled is these reports work on port 8020 directly but not working on 443.
2:48 pm on May 4, 2017 (gmt 0)

New User

joined:May 4, 2017
posts: 6
votes: 0


I believe what i am seeing is the any url's with spaces on 443 are not working.

So, I want to be able to convert the reports ( with spaces ) with underscore as part of the rewrite. I have enabled Proxypass to go to weblogic but that still doesn't help. So, 8020 and 443 pointing to the reports with spaces do not work.
1:28 am on May 5, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13674
votes: 439


I would start by experimenting to confirm that things are what they appear to be. For example:

RewriteCond %{QUERY_STRING} \S\s\S
RewriteRule reports/saw\.dll https://example.com/foo.html [R=302,L]

RewriteCond %{QUERY_STRING} %20
RewriteRule reports/saw\.dll https://example.com/bar.html [R=302,L]
The sole purpose of this experiment is to see what the spaces look like: do they end up at "foo.html" or "bar.html"? (The pages need not really exist. You're just seeing which request gets made.) And then we'll take it from there.
1:44 am on May 5, 2017 (gmt 0)

New User

joined:May 4, 2017
posts: 6
votes: 0


@lucy24, Thanks for the response. The spaces end up at bar.html.

Its strange, that these reports don't work only at 443, but seem to work at 8020, and if I remove the spaces from the URI and replace with + or _, they work.
So, can you please provide a rewrite rule or condition that on 443, any reports under "capublisherEntry" with spaces can be converted to + sign?
2:10 am on May 5, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7472
votes: 500


RewriteCond {ReadMyMind}
RewriteRule {GetItDone} *



* Sadly, this has never worked.
2:43 am on May 5, 2017 (gmt 0)

New User

joined:May 4, 2017
posts: 6
votes: 0


@ tangor +,

I am not sure what you mean. I am very new to this group, and trying to get some help. I am not very familiar with rewrite rules, which is why landed here and trying to get some help. Please let me know if you need more information about the issue.
3:40 am on May 5, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member tangor is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Nov 29, 2005
posts:7472
votes: 500


Sorry. Minor test to see what you know about ReWrite.

Post your current code so we can see what you are doing. We don't write code for you. We help you learn how to do it and point out errors and make suggestions.
6:56 am on May 5, 2017 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:13674
votes: 439


The spaces end up at bar.html.

Yah, thought so. That means you need to stop thinking about literal spaces, and start thinking about the string %20. And some of those URLs might contain more than one space, right? It is technically possible to do more than one of the same thing in mod_rewrite, but it can get messy very fast. I would instead rewrite to a quickie php* script that globally replaces all occurrences of %20 with whatever-else-you-want, and then sends the request back into the world.

* Or other language of your choice, if you're already running something else. You just need something that can follow the instruction "replace all occurrences of ABC with XYZ".
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members