Welcome to WebmasterWorld Guest from 54.163.100.58

Forum Moderators: Ocean10000 & incrediBILL & phranque

htaccess ignoring [G,NC]

   
2:10 pm on Jan 8, 2013 (gmt 0)



Hi All, I am trying to return 410 gone for a few files removed from a domain which has wordpress on it now

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^unwanted/file-directory/file1\.htm$ - [G,NC]
RewriteRule ^unwanted/file-directory/file1\.htm$ - [G,NC]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


The code above works if I comment out the last 2 rewrite rules, but if I leave them like above , server executes them

According to Apache documentation the [L] is implied, but even when I use [G,L] its not working
2:39 pm on Jan 8, 2013 (gmt 0)

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



I guess that internal requests for the ErrorDocument are also being rewritten.

You need to exclude requests for whatever internal path is used to fulfill the 410 from being rewritten. Use an additional negative match RewriteCond before the final rule.
3:37 pm on Jan 8, 2013 (gmt 0)



I edited the code to include the negative match condition as below, but it still just executes the full rules


# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^unwanted/file-directory/file1\.htm$ - [G,NC]

RewriteCond %{REQUEST_URI} !^unwanted/file-directory/file1\.htm$
RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_URI} !^unwanted/file-directory/file1\.htm$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
3:43 pm on Jan 8, 2013 (gmt 0)

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



No. The latter exclusions should be for the internal path and file that serves the 410 error message (e.g.
!^/errors/410\.html
or similar), not for the URL request that triggered the error.
3:51 pm on Jan 8, 2013 (gmt 0)



Thank G1smd, sorry to say but I'm timid with LAMP setup so, what is or how would I find the

"internal path and file that serves the 410 error message"
9:46 pm on Jan 8, 2013 (gmt 0)

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



Let's say it in English.

If a request returns a 410 response, the human user is shown a 410 page-- either your own custom page or Apache's default. (But please do make your own, because the default is intimidating to ordinary humans.)

But this doesn't happen by magic. The server now has to ask internally for that 410 page. ("Internal" means that the user's browser isn't involved, so it won't show up in a {THE_REQUEST} condition.)

Gotta say I don't see the problem though, because you're returning 410 in response to specific filenames, right? The final batch of boilerplate rules ought to mean that if there's a request for any file that really does exist -- such as the 410 page -- it will duly get served up. Unless your rule says "everything in such-and-such directory is Gone" and you've got the 410 page living in that same directory. Then you get an infinite loop.

What exactly happens when the rule "doesn't work"? Insert Tolstoy paraphrase ad lib.

Can we assume that the whole htaccess is located in the right place -- in this case, in a directory where requests for your now-gone files will see it? And that the URL for those now-gone files is exactly as given?

www.example.com/unwanted/file-directory/file1\.htm

like that?
1:37 am on Jan 9, 2013 (gmt 0)



Ok, problem is 410 is not being returned, its a wordpress 404 because the 410 code is being over written so to speak

When the 410 rule fails, the server process the wordpress rewrite rule and serves ups the wordpress friendly 404 response, complete with alternative links.

So I am looking for the default file/path that this apache server uses to report 410, its that which is being re written to wordpress friendly error reporting

been running php apps for a while, so i am usually ok with placing .htaccess
1:13 pm on Jan 9, 2013 (gmt 0)



Okay

I finally fixed this by rewriting to a custom 410 gone php page
 

Featured Threads

Hot Threads This Week

Hot Threads This Month