NAND Logic

Discuss practical ways rearrange URLs using mod_rewrite.

NAND Logic

Postby mynameiszanders » Sat Dec 06, 2008 4:17 pm

Does anyone know of using NAND in RewriteCond just like [OR] can be used?

Basically I want to redirect EVERYTHING on my site to the main index file, except if the request is to a valid file in a certain folder, say example.com/files/

So it translates as:

Code: Select all
if( $is_file && $folder == "^/files/" ) THEN do not redirect.
if( !( !$is_file && $folder != "^/files/" ) ) THEN redirect.


What I want to do, which is completely different to what I'm allowed to do, is:

Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NAND]
RewriteCond %{REQUEST_URI} !^/files/.* [NC]
RewriteRule . /index.php [L]


Any help would be gratefully appreciated!
Thanks, mniz.
mynameiszanders
 
Posts: 3
Joined: Fri Nov 14, 2008 5:09 pm
Location: England

Postby richardk » Sat Dec 06, 2008 4:41 pm

You can do this
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# If it's an existing file in /files/ do nothing.
RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule ^files(/.*)?$ - [L]

# Everything else to /index.php.
RewriteRule . /index.php [L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 1 guest

cron