Forum Moderators: phranque
function curPageURL() {
$url = $_SERVER["REQUEST_URI"];
$path=mysql_result(mysql_query("SELECT path FROM seourls WHERE url='$url'"),0,"path");
return $path
}
curPageURL(); example.com/c5-catname/p4-pagename as the URL will then contain the IDs needed when the PHP script needs to look up the database records in order to serve the page content for this request. href="/friendly-url" in place of the old href="index.php?param=value" format. example.com/index.php?param=value" format is requested, the user is told to make a new request for the example.com/friendly-url" format. For that, you internally rewrite those requests to a special PHP script that looks up the new URL in the database and then uses the PHP HEADER directive to send the correct 301 redirect response. In this case, mod_rewrite does not send the redirect response.
--
-- Table structure for table `seourls`
--
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');
function get_path() {
$url1 = $_SERVER["REQUEST_URI"];
$url = str_replace('/temporaryfolder/', '', $url1);
$startpath=mysql_result(mysql_query("SELECT path FROM seourls WHERE url='$url'"),0,"path");
$add="http://www.mysite.com/temporaryfolder/";
$path = $add.''.$startpath;
header("Location: $path");
}
include 'url_rewrite.php';
get_path();
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) /url_rewrite.php?path=$1 [L,QSA]