Hi everyone
What I am trying to do:
I am trying to rewrite my urls in seo frendly url. For that purpose I create the following table in my database:
CREATE TABLE `seourls` (
`path` varchar(255) NOT NULL,
`url` varchar(255) NOT NULL,
PRIMARY KEY (`path`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `seourls`
--
INSERT INTO `seourls` (`path`, `url`) VALUES ('building-and-construction', 'halls_en.php?fairid=64'),
('online-fair-platform', 'articles.php?artid=89'),
('add-your-company', 'articles_en.php?artid=89'),
('rough-construction', 'companies_en.php?fairid=64&ehallid=118');
Now... I create a php file, named url_rewrite.php Here is the code that I have there:
function get_path() {
$url1 = $_SERVER["REQUEST_URI"];
$url = str_replace('/tempfolder/', '', $url1);
$startpath=mysql_result(mysql_query("SELECT path FROM seourls WHERE url='$url'"),0,"path");
//$add="http://www.mydomain.com/tempfolder/";
//$path = $add.''.$startpath;
//header("Location: $path");
header("Location: $startpath");
}
What is my problem:
I don't know how to proceed further. I know that I have to use .htaccess to rewrite the url stored in $startpath variable, but I don't know to do that. I have very limited knowledge of regular expressions and 0 knowledge of apache.
Anyone can help with the .htaccess code and (if needed) changes of the url_rewrite.php file? My urls must be seo frendly, but I am not sure if the code header("Location: $startpath"); can be considered as seo friendly redirect.
Regards, Zoreli