Forum Moderators: phranque

Message Too Old, No Replies

A basic rewrite

         

vince786

5:53 pm on Oct 25, 2011 (gmt 0)

10+ Year Member



I am a bit confused with a rewrite rule I am working on and would appreciate any feedback.

I have one rule that works well:

RewriteCond %{SERVER_PORT} ^10080$
RewriteRule ^.*/MyApp/index\.jsp [example:10080...] [R=301,L]

I need another rule which says for any other resource requested redirect to an error page:

RewriteCond %{SERVER_PORT} ^10080$
RewriteRule ^.*/MyApp/.* [example:10080...] [R=301,L]

This rule is not working and the resource is served instead of the error page. Any pointers would be greatly appreciated.
Vince

g1smd

6:27 pm on Oct 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



By using a leading uncaptured .* pattern in your RegEx, one that you fail to pass on and check the value of, you
1. promote infinite duplicate content,
2. slow your server massively as it has to make thousands of "back off and retry" trial matches for every incoming request.

Never use .* at the beginning or in the middle of a RegEx pattern.

Why do you need to "redirect" to an error message? Why don't you just serve the message as a response to the auto-detected 404 error?

vince786

7:15 pm on Oct 25, 2011 (gmt 0)

10+ Year Member



Thanks g1smd for correcting me on the usage of .*.
I have one more basic question. I am using this rewrite rule to "lock" the application ie force login screen for authenticating users. I'm having second thoughts whether this is a good idea in the first place and instead use tomcat's Realm to go against LDAP.