I have a .htaccess file with the following rules:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
In the index.php I have:
$route = (isset($_GET['route'])?explode('/',$_GET['route']):null);
if(!empty($route)){
$route[0]; //movie
//$route[1]; //movie-name
header("Location: " . "http://192.167.1.189/site_name/movie/" . $route[1]);
// $route[1] = 2271 (movie id)
exit;
}
The goal is to get from this url:
http://192.167.1.189/site_name/movie-page.php?id=2270
to this url:
http://192.167.1.189/site_name/movie/2270
I will also want some other url changes such as .../movie-page.php to .../movie/ and so on...
I understand why I get the redirect loop, but I don't know how to fix it. How can I redirect all (except valid files and directories such as css files and images) to a central php file and then redirect to the user friendly url?
http://192.167.1.189/site_name/? Is the htaccess file sitting in 192.167.1.189's document root?