Forum Moderators: phranque

Message Too Old, No Replies

Wrong error codes for just some filetypes

         

mattdamon

12:35 am on Feb 28, 2012 (gmt 0)

10+ Year Member




System: The following 10 messages were cut out of thread at: http://www.webmasterworld.com/apache/4422152.htm [webmasterworld.com] by tedster - 7:52 pm on Feb 28, 2012 (EDT -5)


Hi All,
I am facing an issue with IBM Https Server
pages with .jhtml and .rss extension are throwing proper 404 error when an resource not found uri is entered.
But pages .jpeg and other are throwing error code 302 couple of times and then redirecting to 404.
I did not write any redirect rule for .jpeg but still how its giving 302.
This is the rule for jhtml and rss.

RewriteRule ^/([a-zA-Z0-9]{2}_([a-zA-Z0-9]{2}))/\2/(.*)(jhtml)(\?)*(.*)$ redirection-url [QSA,NC,L,PT]
RewriteRule ^/([a-zA-Z0-9]{2}_([a-zA-Z0-9]{2}))/webadmin(.*)(\.rss)(\?)*(.*)$ redirection-url [QSA,L,PT]

Please suggest !

g1smd

1:19 am on Feb 28, 2012 (gmt 0)

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



That code above is neither a redirect nor rewrite. It's configured as a Reverse Proxy.

throwing error code 302

302 is not an "error code", it's a temporary redirect.

then redirecting to 404

404 is an error code; it is not a "redirect".

There are serious issues with the code sample you supplied, not least the multiple inappropriate (.*) patterns.

What is all that
(\?)*(.*)$
stuff after the file extension for?

With a leading / in the RegEx pattern I assume this code is in the httpd.conf file and not in htaccess.

lucy24

2:03 am on Feb 28, 2012 (gmt 0)

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



What is all that (\?)*(.*)$ stuff after the file extension for?

I think it means it's time for a re-post of the Query String boilerplate.

:: wandering off to look for it ::

mattdamon

5:51 pm on Feb 28, 2012 (gmt 0)

10+ Year Member



Yes it is in the https.conf file and not htaccess.
What is all that (\?)*(.*)$ stuff after the file extension for?
it works for uri asdf.asdf.com/qwer.jhtml?asdf
My question here is without writing any rewrite rules for extension jpeg how its redirecting with status code 302.

the jhtml extensions are showing expected behaviour

mattdamon

5:53 pm on Feb 28, 2012 (gmt 0)

10+ Year Member



I just wrote the rules to show that the Rules for jhtml and rss is working fine.
Also throw light on how you understand that theyare configured as reverse proxy

g1smd

6:31 pm on Feb 28, 2012 (gmt 0)

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



The RewriteRule RegEx pattern cannot ever see attached parameters, so it does not see the ?query part of the requested URL. The query string is either re-attached to the target unchanged unless you add code to either replace the query string or remove the query string.

Yes, not a Proxy, thats [P]. It was late when I posted. See the Apache manual for detailed information on the [PT] flag especially [httpd.apache.org...]

mattdamon

7:06 pm on Feb 28, 2012 (gmt 0)

10+ Year Member



ok .. thanks for the info..

Could you sugest on how status code 302 is being showing for which I have not even rewrite rule (jpeg extension)
also what should i do to make the jhtml and jpeg extension URI behave in in a same way..
Can you share your email id then i can send the redirect file.

mattdamon

7:12 pm on Feb 28, 2012 (gmt 0)

10+ Year Member



Also how can i check in httpd.conf whether the default 404 error page is overriden or not.

Thanks

mattdamon

7:16 pm on Feb 28, 2012 (gmt 0)

10+ Year Member



Issue brief:

When i hit URL [sdf.xcv...] - in fiddler it shows 302 status code

But wen i hit [sdf.xcv...] - it shwos 404.

I want [sdf.xcv...] also to sho 404 in fiddler.

Thanks

lucy24

11:17 pm on Feb 28, 2012 (gmt 0)

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



OK, let's get this straight...

Requests for nonexistent jpg files get redirected. It's a 302, which means either a Redirect in mod_alias or a [R] flag in mod_rewrite. Redirects don't happen by themselves.*

Requests for nonexistent .jhtml get the proper 404. So we don't need to do anything about those.

Have you looked at your logs? When there is a redirect, the original request should be followed immediately by a second request for the name of the file you're being redirected to.

Is it your own server? You can set the error logs to "Debug" level, though it may not help with the 302's.

RewriteRule ^/([a-zA-Z0-9]{2}_([a-zA-Z0-9]{2}))/\2/(.*)(jhtml)(\?)*(.*)$ redirection-url [QSA,NC,L,PT]
RewriteRule ^/([a-zA-Z0-9]{2}_([a-zA-Z0-9]{2}))/webadmin(.*)(\.rss)(\?)*(.*)$ redirection-url [QSA,L,PT]

Is that a direct cut-and-paste from your config file or htaccess? It's an awful mess-- sorry!-- but I noticed one thing. The first rule doesn't actually say anything about a jhtml extension. That is, you say \.rss but you don't say \.jhtml. That means that anything containing the string "jhtml" would be sent over to
redirection-url [QSA,NC,L,PT]
You don't happen to have files named blahblahjhtmlblahblah.jpg do you?

What does \2 refer to?


* OK, sometimes they do, but not in ways that apply here. For example, mod_speling might kick in if you ask for
fielname.html
and it doesn't exist but you do have a
filename.html
There are also directory-slash redirects and maybe with/without www redirects. But all of those should come through as 301.

g1smd

1:33 am on Feb 29, 2012 (gmt 0)

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



Is your "redirection-url" merely a path or path and parameters or is it in a full URL complete with protocol and hostname?