Q: custom .htaccess rewrite rules I want to redirect all to one script e.g. index.php?url=inputurl 
With if/else I want to parse url
in index.php run query for url in my custom table


*

*if url is mach: echo "ok"

*else do nothing


How should I set .htaccess in root folder of Wordpress?
Example:
URLs in custom_table:


*

*asd

*dfg

*ghj


If user puts:
www.mysite.com/asd
-> mod_rewrite should output this: www.mysite.com/index.php?url=asd
Else if user puts:
www.mysite.com/zzz
-> do nothing

A: I think the following .htaccess should solve the problem:
RewriteEngine On

# Redirects everything that is not index.php to index.php
RewriteCond $1 !^index\.php
RewriteRule ^(.*)$ index.php?url=$1 [L,R]

Edit: to not include your folders and files (like /js, /css, etc.) in rewrite, add the following lines before the RewriteRule line (see comments):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

And in the PHP script:
$url = $_GET['url'];

// the method is_valid should check if the page exists in DB
if (is_valid($url)) {
    // do something here
    // maybe redirect with header('Location: path')
} else {
    // show a not found page (error 404)
}


A: You want to both be able to read from a database and do nothing if there is not match.
This would require you run code to access db then return back to apache to process and is not possible from .htacccess (though it is from httpd.conf).
The .htaccess solution would be to specify all the "table" entries inline as below.
RewriteEngine on
RewriteBase /

#if asd or dfg or ghj
RewriteCond %{REQUEST_URI} ^/(asd|dfg|ghj) [NC]
RewriteRule . index.php?url=%{REQUEST_URI} [L]

