Guy.. I am baffled. I've got a fundamental rewrite flow which i can't appear to obtain working. I wish to see if a genuine-file is available. Whether it does, serve it, but when it does not, reroute to some PHP file. Here's my .htaccess file:

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/application%{REQUEST_URI} !-f
RewriteRule ^(.*)$ core/index.php?f=%{DOCUMENT_ROOT}/application%{REQUEST_URI} [QSA,L]

RewriteRule (.*) application/$1 [L]

My directory structure is the following:

.
├── [drwxr-xr-x]  application
│   └── [-rw-r--r--]  test.html
├── [drwxr-xr-x]  core
│   ├── [-rw-r--r--]  index.php
│   └── [drwxr-xr-x]  tmp
│       ├── [-rw-r--r--]  httpd-access.log
│       ├── [-rw-r--r--]  httpd-error.log
│       └── [-rw-r--r--]  rewrite.log
└── [-rw-r--r--]  .htaccess

3 directories, 6 files

Listed here are the permission I'd appreciate any help. Thanks.

Are you certain your Apache has mod rewrite switched on?

Maybe you can include RewriteBase / or RewriteBase % directive immediately after RewriteEngine On

To become put into .htaccess in root folder. Should you likely to devote in config file (inside <VirtualHost> for instance) then it must be slightly modified.

RewriteEngine On
RewriteBase /

# 1) do not do anything for existing file or folder
RewriteCond %{ENV:REDIRECT_STATUS} !^$
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .* - [L]

# 2) real file (in application folder) -- rewrite path
RewriteCond %{DOCUMENT_ROOT}/application%{REQUEST_URI} -f
RewriteRule (.*) /application/$1 [L]
# 3) nope, no such file -- serve via index.php
RewriteRule ^(.*)$ /core/index.php?f=%{DOCUMENT_ROOT}/application%{REQUEST_URI} [QSA,L]

The key factor that lots of people failing to remember about, is always that after URL was rewritten it is going to next iteration. As well as on such next iteration URL has already been dissimilar to the initially asked for. These rules should be mindful relating to this moment.

This is the way it is useful for /test.html:

  1. Rule #1 is going to be missed as there's no /test.html
  2. Rule #2 works, as there's personal files /application/test.html. Rewrite would go to next iteration ([L] flag).
  3. Rule #1 will act as URL now's /application/test.html and the like file does exist. This rule informs Apache to prevent spinning any more -- task finished.

This is the way it is useful for /meow.html:

  1. Rule #1 is going to be missed as there's no /meow.html
  2. Rule #2 is going to be missed as there's no file /application/meow.html.
  3. Rule #3 works -- URL rewritten to core/index.php?f=%{DOCUMENT_ROOT}/application/meow.html. Rewrite would go to next iteration ([L] flag).
  4. Rule #1 will act as URL now's /core/index.php and the like file does exist. This rule informs Apache to prevent spinning any more -- task finished.

EDIT: You might add leading slash / before destination a part of RewriteRule (should not be a difference ... however your setup might be a little not the same as mine).