homepage Welcome to WebmasterWorld Guest from 54.196.198.213
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
htaccess ignoring [G,NC]
scooterdude




msg:4534298
 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

 

g1smd




msg:4534307
 2:39 pm on Jan 8, 2013 (gmt 0)

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.

scooterdude




msg:4534322
 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

g1smd




msg:4534324
 3:43 pm on Jan 8, 2013 (gmt 0)

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.
scooterdude




msg:4534328
 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"

lucy24




msg:4534456
 9:46 pm on Jan 8, 2013 (gmt 0)

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?

scooterdude




msg:4534508
 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

scooterdude




msg:4534631
 1:13 pm on Jan 9, 2013 (gmt 0)

Okay

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved