0) { $row = mysqli_fetch_assoc($result); // ✅ If URL is accessed via ID, redirect permanently to canonical slug if (isset($_GET['id']) && is_numeric($_GET['id'])) { header("HTTP/1.1 301 Moved Permanently"); header("Location: " . $row['url']); exit; } // ✅ Else: proceed normally (already on clean slug) // process $row here to display the post } else { // ❌ No post found header("Location: 404.php"); exit(); } $post_id = $row['id']; //pageview count query $page=$row['title']; $count="SELECT * FROM page_hits WHERE page='".$page."'";$feedback=mysqli_query($GLOBALS["___mysqli_ston"],$count) or die ( ((is_object($GLOBALS["___mysqli_ston"]))? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ?$___mysqli_res : true))); $roo=mysqli_fetch_assoc($feedback); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $host = isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost'; $requestUri = $_SERVER['REQUEST_URI']; $pathParts = explode('/', trim($requestUri, '/')); $subdomain = explode('.', $_SERVER['HTTP_HOST'])[0]; $domain = explode('.', $_SERVER['HTTP_HOST'])[1]; $parts = explode('.', $host); $domain1 = $parts[0]; $brand = ucwords(str_replace('-', ' ', $domain1)); $author = isset($row['author']) && trim($row['author']) != '' ? $row['author'] : $brand; if (strcasecmp($author, 'admin') === 0) { $author = $brand; } $currentUrl = $protocol .$host. $requestUri; $currentUrl = urldecode($currentUrl); if (strlen($domain)<4) { $host=$host.str_replace('/single.php','',strtolower($_SERVER['PHP_SELF'])); } //$firstPathSegment = (count($pathParts) > 1) ? '/' . $pathParts[0] : ''; //} //else //{ // $currentUrl = "**".$protocol . $host . $requestUri; //} $image =$row['photo']; if (strpos(strtolower($image),"https://") !== false) { //file_put_contents("links.txt",$image, FILE_APPEND | LOCK_EX); //$image='shit'; //$griditem['photo']; } else { //file_put_contents("nolink.txt",$image.chr(13), FILE_APPEND | LOCK_EX); $image=$protocol . $host.'/blogadmin/images/'.$row['photo']; } $seodesc= str_replace(["\r\n", "\r", "\n"], ' ',preg_replace('/\s+/', ' ',trim(substr(strip_tags($row['content']),0,250)))).'...'; $seodesc = strlen($seodesc) > 150 ? substr($seodesc, 0, 150) : $seodesc; $seodesc .= "..."; if (!isset($row['seo_title']) || trim($row['seo_title']) === '') { $seo_title= $row['title']; } else { $seo_title= $row['seo_title']; } if (!isset($row['seo_tags']) || trim($row['seo_tags']) === '') { if (empty($row['tags']) || $row['tags'] === null || $row['tags'] === 0) { $seo_tags= "Sithars Astrology Software, Best Astrology Software"; } else { $seo_tags =$row['tags']; } } else { $seo_tags= $row['seo_tags']; } if (!isset($row['seo_desc']) || trim($row['seo_desc']) === '') { $seo_desc= $seodesc; } else { $seo_desc= $row['seo_desc']; } $seo_desc = htmlspecialchars($seo_desc, ENT_QUOTES, 'UTF-8'); // -------------------------------- // 3. Language detection (based on category) // -------------------------------- // Default language $langCode = 'en'; $langName = 'English'; // Check for Tamil (safe multibyte check) if (!empty($category_name)) { // Option 1: simple English word check if (preg_match('/tamil/i', $category_name)) { $langCode = 'ta'; $langName = 'Tamil'; } // Option 2: fallback — detect Tamil characters elseif (preg_match('/[\x{0B80}-\x{0BFF}]/u', $category_name)) { $langCode = 'ta'; $langName = 'Tamil'; } } ?> <?php $host = parse_url("https://" . $_SERVER['HTTP_HOST'], PHP_URL_HOST); // Extract site name (remove .com, .org, .net, etc.) $site_name = preg_replace('/\.(com|org|net|in|co\.uk|edu)$/i', '', $host); switch (strtolower($site_name)) { case "quicktechsupport": $formatted_site_name = "Quick Tech Support"; break; case "sitharsastrology": $formatted_site_name = "Sithars Astrology"; break; case "kovaiyellowpages": $formatted_site_name = "Kovai Yellow Pages"; break; default: // Fallback: Convert to title case with spaces $formatted_site_name = ucwords(str_replace("-", " ", $site_name)); } // Check if title already contains the site name (case-insensitive) if (stripos($seo_title, $formatted_site_name) === false) { $seo_title .= " | " . $formatted_site_name; } echo (strlen($seo_title) > 60) ? substr($seo_title, 0, 60) . "..." : $seo_title; ?> 0) { $cat = mysqli_fetch_assoc($category_data); $category_name = $cat['slug']; // slug $category = $cat['name']; // name } else { $category_name = 'general'; $category = 'General'; } // build slugs safely (simple slugify - lower, spaces -> hyphen, remove non-alnum/hyphen) function slugify($s){ $s = strtolower(trim($s)); $s = preg_replace('/\s+/', '-', $s); $s = preg_replace('/[^a-z0-9\-]/', '', $s); $s = preg_replace('/-+/', '-', $s); return $s; } // $base_url = ( (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT']==443 ) ? 'https://' . $_SERVER['HTTP_HOST'] . '/' : 'http://' . $_SERVER['HTTP_HOST'] . '/'; // if you prefer hard-coded base URL, replace above with: $base_url = 'https://sitharsastrology.com/'; //$categoryPrefix = $is_kovaiyellowpages ? '/' : '/blog/'; // Build breadcrumb items $items = []; // Home $items[] = [ "@type" => "ListItem", "position" => 1, "item" => [ "@id" => BLOGURL, "name" => "Home" ] ]; // Category (only if available) if (!empty($category_name)) { $items[] = [ "@type" => "ListItem", "position" => 2, "item" => [ "@id" => BLOGURL.'category/'.slugify($category_name), "name" => $category ] ]; } // Current page (canonical) $canonicalUrl = strtok($currentUrl, '?#'); $items[] = [ "@type" => "ListItem", "position" => count($items) + 1, "item" => [ "@id" => $canonicalUrl, "name" => $row['title'] ] ]; $breadcrumb = [ "@context" => "https://schema.org", "@type" => "BreadcrumbList", "name" => "Breadcrumbs", "itemListElement" => $items ]; ?> "> " /> '; } if (!empty($row['howto'])) { $lines = preg_split("/\r\n|\n|\r/", trim($row['howto'])); echo('
'); echo '

How To?

'; foreach ($lines as $line) { if (strpos($line, '|') !== false) { list($title_part, $desc_part) = explode('|', $line, 2); $step_title = trim(preg_replace('/^Step:\s*/i', '', $title_part)); $step_desc = trim($desc_part); echo '
'; echo '

' . htmlspecialchars($step_title, ENT_QUOTES) . '

'; echo '

' . nl2br(strip_tags($step_desc, ENT_QUOTES)) . '

'; echo '
'; } } echo('
'); } if (!empty($row['appendbody'])) { echo '
'.$row['appendbody']; // extra content only if it exists } echo '

Similar Posts : '.generatesimilarposts($row['tags'],5).'

'; echo 'See Also:'.str_replace(['
  • ', '
  • '], '',generateindividualtags($row['tags'])); ?>