Forum Moderators: phranque

Message Too Old, No Replies

Where to put 410 Gone in well annotated .htaccess file?

L flag? - internal & external redirects? - deferred redirect flags?

         

Robert Charlton

7:06 am on Apr 15, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I have a site with a well-annotated but complex .htaccess file, and I need to put a 410 Gone message in the .htaccess file to indicate that I'm permanently deleting dumpedfile.html.

As you'll see, I'm not yet completely familiar with the structure of an .htaccess file, so, even with the best annotation, I'm not comfortable making some additions.

This, I believe, is the syntax for the rule....

RewriteRule ^dumpedfile\.html$ - [G]

I'm assuming...

a) that this rewrite is what's called an "external" rather than an "internal redirect" (but I can't find definitions of these)...

b) that, like the Rewrite Rules that redirect old pages to new pages, it doesn't need a Rewrite Condition

c) that the last 410 Gone rewrite should have an L flag

d) that it should probably follow my canonical "www" rewrites... and that it should precede any sections that rely on "deferred external redirect flags."

So, this rewrite should be...

RewriteRule ^dumpedfile\.html$ - [G,L]

Do I have it right?

As a PS to this, would value input on internal and external redirects, redirect flags, and deferred external redirect flags.

jdMorgan

4:32 pm on Apr 15, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a) It does not invoke a redirect, but rather a 410-Gone response.
b) Are there any conditions under which the 410-Gone response should not be returned in response to a request for this page? If not, then you don't need a RewriteCond.
c) No, a [G] acts immediately, and includes an implicit [L]. The same is true for the [F] and [P] flags.
d) No, there's no use in canonicalizing a non-existent page -- It's gone. Put it ahead of the domain redirects.
e) See (c) above.

Deferred external redirect: An external redirect that is deferred so that other more-specific conditions can be checked before executing that redirect as a default corrective action.

[added] An internal rewrite changes the file associated with an incoming HTTP URL request; The client is unaware of this change.

An external redirect changes the URL associated with the requested resource and requires client interaction. That is, the server's redirect response terminates the current HTTP transaction with a message that says, "That resource has moved, ask for it again at this new URL." The client must then begin a new HTTP transaction, asking for the originally-requested resource at the new URL given in the server's redirect response. In doing so, a client browser will update its address bar, showing the new URL, whereas a search engine robot client will (hopefully) update its URL database if the redirect response indicated a 301-Moved permanently redirect.[/added]

Jim

[edited by: jdMorgan at 4:41 pm (utc) on April 15, 2007]

g1smd

4:49 pm on Apr 15, 2007 (gmt 0)

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



Since it is for a specific file, it goes at, or near, the beginning of all of your redirects and canonicalisation code.

You would not redirect non-www to www for that filename and then serve the 410 for the www version. You would directly serve 410 for that filename irrespective of whether www or non-www had been in the original request.

Robert Charlton

6:20 pm on Apr 16, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Jim and g1smd - Thanks for your helpful comments, and for the ongoing education.

Is there a thread or online documentation anywhere just about the flags? I'd find it helpful.

Thanks.

jdMorgan

6:42 pm on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't know of any credible documentation on the flags, other than the Apache RewriteRule documentation [httpd.apache.org] itself.

In each case, the word "immediately" means that no [L] flag is needed:

o 'forbidden¦F' (force URL to be forbidden)
This forces the current URL to be forbidden, i.e., it immediately sends back a HTTP response of 403 (FORBIDDEN). Use this flag in conjunction with appropriate RewriteConds to conditionally block some URLs.

o 'gone¦G' (force URL to be gone)
This forces the current URL to be gone, i.e., it immediately sends back a HTTP response of 410 (GONE). Use this flag to mark pages which no longer exist as gone.

o 'proxy¦P' (force proxy)
This flag forces the substitution part to be internally forced as a proxy request and immediately (i.e., rewriting rule processing stops here) put through the proxy

(Emphasis added)

Clear and concise, IMO... :) One reason that mod_rewrite and other Apache documents are so terse is that in many cases, the file-size of the documentation Webpage exceeds the file-size of the module itself. That is the nature of Apache-specific code.

Jim

Robert Charlton

7:38 am on Apr 28, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Jim - Once again, thanks....

In each case, the word "immediately" means that no [L] flag is needed....

...(Emphasis added)

Clear and concise, IMO... :) One reason that mod_rewrite and other Apache documents are so terse is that in many cases, the file-size of the documentation Webpage exceeds the file-size of the module itself. That is the nature of Apache-specific code.

Concise, yes... and clear with your clarification and emphasis added. Otherwise, perhaps too concise for someone who's not conversant with the terminology and not immersed in it frequently.

Many years back, I was a media consultant to a National Science Foundation project that was exploring problems of teaching math and physics to elementary and high school students. One of the discoveries that the mathermaticians and scientists had a hard time accepting was that students most often failed to understand apparently clear instructional material intended for them because the material overestimated the knowledge level the students brought with them. Unfamiliarity with specialized vocabulary was consistently a problem.

Obviously, Apache documentation is not for non-professionals, and I've got to confess that I often have difficulty reading it. I'm still looking for that fabled introductory book... one with a really good index and glossary that would also serve for reference.

g1smd

8:20 pm on Apr 28, 2007 (gmt 0)

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



I also find it too concise, just a few extra words of clarification would make all the difference between bewilderment and understanding.

KenB

1:38 am on Apr 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Today I upgraded both Apache (from 1.3 to 2.2) and PHP (from 4.0 to 5.0) on my laptop that I use for development and I found the documentation for both to be extremely frustrating and I'm no slacker on this stuff. In fact PHP's install documentation was wrong in several key aspects, which added to the frustration. I spent hours digging through the Internet piecing together bits of advice unto I finally got everything playing nicely with each other.

I'm dreading the upgrade from MySQL4 to MySQL5.

[edited by: KenB at 1:40 am (utc) on April 29, 2007]

g1smd

5:59 pm on Apr 29, 2007 (gmt 0)

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



I recently installed Apache 2 on one machine, and added PHP 4 to an existing Apache 1.3 install on another.

I spent many hours going round in circles after a careless slip which I overlooked.