-f parameter ignored?

Can you help me find out what’s wrong with this?

I’m not an Apache programmer, one of the few things I thought I do know is that -f means “is not a file”, which triggers when “not found”, but now i doubt it.

These are my rules, and the problem is that the verification file from google e.g. /8377rsomecode.html is not found (it’s a real file, not a wordpress page)

It should be NOT catched by line marked with ***********

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)\\.html http://%{SERVER_NAME}/$1 [R=301,L]
#
RewriteCond %{HTTP_HOST} =!blog/page/.*
RewriteCond %{HTTP_HOST} =!blog/tag/.*
RewriteCond %{HTTP_HOST} =!blog/category/.*
RewriteRule ^blog/(.*) http://%{SERVER_NAME}/$1 [R=301,L]
# remaining.html files
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\\.html$ /$1 [R=301,L]************
#
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Sergio,

The -f will match a file which exists just as -d will match a directory which exists. The !-f and !-d negate these, i.e., if the request is neither a file nor directory, then …

Other problems:

  1. [rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/rant 4]

OMG! Not only do you make this test once but TWICE!

  1. What does “catched” (cached) have to do with mod_rewrite code?

  2. Other coding problems:

[COLOR="#FF0000"]<IfModule mod_rewrite.c>
# Where did this get closed?[/COLOR]
RewriteEngine On
[COLOR="#FF0000"]RewriteBase /[/COLOR]
[COLOR="#808080"]# strip blog from URI[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)\\.html [COLOR="#FF0000"]http://%{SERVER_NAME}/[/COLOR]$1 [R=301,L]
#
[COLOR="#B22222"]# This code will never be matched/redirected as the above block will have removed blog/
RewriteCond %{HTTP_HOST} [COLOR="#FF0000"]=[/COLOR]!blog/page/.*
RewriteCond %{HTTP_HOST} [COLOR="#FF0000"]=[/COLOR]!blog/tag/.*
RewriteCond %{HTTP_HOST} [COLOR="#FF0000"]=[/COLOR]!blog/category/.*
RewriteRule ^blog/(.*) [COLOR="#FF0000"]http://%{SERVER_NAME}/[/COLOR]$1 [R=301,L][/COLOR]
# remaining.html files
[COLOR="#808080"]# Strip .html extension from non-file requests[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\\.html$ /$1 [R=301,L]************
#
# BEGIN WordPress
[COLOR="#FF0000"]<IfModule mod_rewrite.c>[/COLOR]
RewriteEngine On
[COLOR="#FF0000"]RewriteBase /[/COLOR]
[COLOR="#FF0000"]RewriteRule ^index\\.php$ - [L]
# doesn't index.php exist? !-f will be sufficient[/COLOR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .[COLOR="#EE82EE"]?[/COLOR] /index.php [L]
[COLOR="#EE82EE"]# Handle empty request, too![/COLOR]
[COLOR="#FF0000"]</IfModule>[/COLOR]

# END WordPress

[/QUOTE]

From your use of “canned” code without understanding even the basics, I need to recommend the tutorial linked in my signature. It’s helped others and should help your understanding. The sample code explanations should also help.

Regards,

DK

The -f will match…
I know. No insults here? :frowning:

1- The definition of a Master idiot and Idiot-phobic is those who think other people is asking questions because they are idiots, and ignore there are other causes for the questions, like I’m not an Apache programmer, not a formal programmer at all. I just learned PHP and Basic and JavaScript and ActionScript by using it. Enough for me to still develop wordpress sites and “ask” for help, as the first line of the message said.

1-a I didn’t know there are a [rant] shortcode. You are very ingenious and have an original way to help. Would you help people who are not idiots? How do you tell? They speak proper english? Do you know only ONE language?

1-b I’d rather open it and close it twice than messing with WP code, because everything inside #Begin WordPress comments will be overridden in the next page load.

3- “Catched” wanted to be the past for “Catch”, or the misspelling for “caught”. Will you help people with grammar and spelling errors? Does your brain consider an idiot to everyone with less experience than you? Is there a limit? A quantum physics scientist asking for help to code his website with front-page (if still exists) is an idiot too? Should a person knowing one more language than you or cooking better barbecues than yours consider you an “idiot” if he/she had your stupid brain? ir is it a defect in DNA not related to a brain defect?

 # This code will never be matched/redirected as the above block will have removed blog/
RewriteCond %{HTTP_HOST} =!blog/page/.*
RewriteCond %{HTTP_HOST} =!blog/tag/.*
RewriteCond %{HTTP_HOST} =!blog/category/.*
RewriteRule ^blog/(.*) http://%{SERVER_NAME}/$1 [R=301,L]

The code above this ( specifically ^blog/(.*)\.html ) was expected to remove blog/ ONLY to pages containing .html AND blog/ , and IT DID, but it was removing .html to ALL the requests, even the ones which didn’t have bog/.
I fixed it adding RewriteCond %{HTTP_HOST} =/blog/.* to the first rule and it totally works now.

It was the main request of this topic and You totally missed it. I hope helps others.

&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
# doesn't index.php exist? !-f will be sufficient
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? /index.php [L]
# Handle empty request, too!
&lt;/IfModule&gt;

You can send a ticket to WordPress team with your narrow opinions so they can re-evaluate their world’s-most-used cms platform for that last code. They must be idiots too.

Thank you!

Sergio,

I apologize for writing in a manner which you found offensive. I can assure you that offense was not intended and recommend that you look though the “offensive” words for all the useful information there.

Regards,

DK