Search code examples
php.htaccessmod-rewritehttp-redirecttinyurl

mod_redirect every request except a.php, b.php and c.php


I have searched Google and looked here but I haven't quite found the answer I am looking for.

I am working on a little project and part of it will allow shorturl redirects, similar to bit.ly or tinyurl.com.

I would like to allow visitors to be able to view pages a.php, b.php and c.php but everything else such as; domain.com/blahblahblah or domain.com/FirstName will be redirected to c.php which will look at the URL, then look in the DB to see if there is a matching value. If there is then redirect them.

I have everything done except the catch all mod_redirect / .htaccess redirect.

Thanks for the help.


Solution

  • RewriteEngine on
    RewriteCond $1 !^(a\.php|b\.php|c\.php)
    RewriteRule ^(.*)$ c.php?q=$1 [L]