Create additional url in sitemap
I am trying to create a sitemap for my site. so far I've managed to build it.
Now I notice that I have URLs linked to other URLs. which contain 90% of my site urls.
For example, I have this url:
www.mysite.com/mainurl
and those urls that are associated with the above url:
www.mysite.com/mainurl/mypage1 www.mysite.com/mainurl/mypage2 www.mysite.com/mainurl/mypage3
I was wondering if there is a way to associate secondary urls with the first url, something like sub url.
Also I have another question, what type of URL format should I use?
This type: www.mysite.com/mainurl
or this type:www.mysite.com/page.php?url=mypage1
source to share
Perhaps consider using PHP's break function to split the url, then compare the values in a loop, like so:
$items = get_your_array();
foreach($items as $item)
{
$urlParts = explode...
foreach($urlParts as $part => $val)
{
// Organise parts into an associative array, so you can loop over it later
// This would produce something that also could be accessed like...
// $items['www.mysite.com']['mainurl']['mypage1'];
// $items['www.mysite.com']['mainurl']['mypage2'];
// Having the array key the same as the value as it would probably filter out duplicates, so you need to consider that
}
}
As for your second questions, use the first url style, they are better for SEO.
source to share