Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite to check query string?

         

paultan

3:37 pm on Sep 19, 2008 (gmt 0)

10+ Year Member



Hello all!

I have a virutal location to expose webservices on the internet. The path is /webservices, followed by some path information, like /webservices/product/getProduct.

Now I want to limit access to this webservices only for POST requests. However, it should be possible to GET the wsdl, which is located at /webservices/product/getProduct?wsdl.

I have created a LocationMatch directive:

<LocationMatch /webservices>
<Limit GET>
Order Deny,Allow
Deny from all
</Limit>
</LocationMatch>

But now it's not possible to GET /webservices/product/getProduct?wsdl. Is it possible to use rewriting to solve this?

Thanks in advice!

- brgds, Paul

jdMorgan

3:41 pm on Sep 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, a RewriteRule examining the requested URI, and one or more RewriteConds examining REQUEST_METHOD, and possibly QUERY_STRING should do it.

Jim

paultan

4:05 pm on Sep 19, 2008 (gmt 0)

10+ Year Member



Thanks for your reply!
Do you know how to construct those Rewrite rules? I have tried something like

RewriteCond %{QUERY_STRING} ^!wsdl$
RewriteRule .* [F]

But it doesn't work...

jdMorgan

5:36 pm on Sep 19, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your "!" and "^" are reversed. You have no check for the HTTP Method. You did not specify any URL-path in the RewriteRule pattern.

Please see the resources cited in our Forum Charter [webmasterworld.com] to help you get started. You will be far better off with code that you understand and can maintain...

Thanks,
Jim