Wednesday, December 28, 2011

If not found, redirect to a different URL to check

SkyHi @ Wednesday, December 28, 2011

# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.

RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^/\.]+)$$1 [L]

require_once ("functions.php");
$db = new db_mysql();
$file_db = $db->getValue ("SELECT pl_name FROM promo_link");
$file_db2 = $db->getValue ("SELECT sl_name FROM specials_links");

$str_arr = explode ("/", $str);
$file_name = $str_arr[count ($str_arr) - 1];

if ($file_name == $file_db) {
   header ("Location: promotions/booking.php");

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

... means that if the file with the specified name in the browser doesn't exist, or the directory in the browser doesn't exist then procede to the rewrite rule below