Repository navigation
Expand file tree
/
Copy pathsitemap.php
More file actions
49 lines (36 loc) · 1.52 KB
/
Copy pathsitemap.php
File metadata and controls
49 lines (36 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
//sitemap.php to sitemap.xml using .htaccess file
require_once('include/db.php');
$courses = $db->query('SELECT * FROM courses ORDER BY id ASC');
//define your base URLs
//Main URL
$base_url = "http://aptieco.com";
//Page base URL
$courses_base_url = "https://aptieco.com/courses?id=";
header("Content-Type: application/xml; charset=utf-8");
echo '<!--?xml version="1.0" encoding="UTF-8"?-->'.PHP_EOL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . PHP_EOL;
echo '<url>' . PHP_EOL;
echo '<loc>'.$base_url.'</loc>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
echo '<url>' . PHP_EOL;
echo '<loc>'.'https://aptieco.com/courses'.'</loc>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
echo '<url>' . PHP_EOL;
echo '<loc>'.'https://aptieco.com/aboutus'.'</loc>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
echo '<url>' . PHP_EOL;
echo '<loc>'.'https://aptieco.com/contactus'.'</loc>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
while($data = $courses->fetch()){
echo '<url>' . PHP_EOL;
echo '<loc>'.$courses_base_url.$data["id"] .'</loc>' . PHP_EOL;
echo '<changefreq>daily</changefreq>' . PHP_EOL;
echo '</url>' . PHP_EOL;
}
echo '</urlset>' . PHP_EOL;
?>