Page 1 of 1
XML Sitemap being created in wrong directory
Posted: Mon Dec 28, 2009 4:40 pm
by JimFriend
So I originally I had a multi-store setup working where two stores shared the same database. That was working fine, but my client wanted to split the sites in the end so that he had two sites running on two separates databases. I accomplished this fine. Everything is working as I would expect it to except for the XML Sitemap functionality. For some reason, when I create the XML Sitemap on the secondary site (we'll call it Site B) the actual file is created in Site A's root directory. The information inside of the file is correct (it has Site B's info) -- it's just where the file is created that is the problem.
The code that handles the sitemap creation hasn't been touched at all on either site (/Admin/Website/CommonXLMSitemap). So I'm assuming the problem is that there is some leftover setting somewhere (web.config? database field? somewhere else?) that is causing the sitemap for Site B to be created in the root directory of Site A instead of Site B's root directory.
The situation is a bit confusing so if I need to do a better job of explaining please let me know.
Thanks in advance.
Re: XML Sitemap being created in wrong directory
Posted: Tue Dec 29, 2009 3:36 am
by mazhar
I am not sure but try following and see what happens. First take backup of you
Admin/Website/CommonXMLSiteMap.aspx.cs file and then locate following code
Code: Select all
options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);
update it as
Code: Select all
options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);
string path = Server.MapPath(Token.Instance.Store.StoreUrl);
if(!path.EndsWith("\\"))
path+="\\";
options.SiteMapDataPath = path;
Now again generate the sitemap and see where it goes.
Re: XML Sitemap being created in wrong directory
Posted: Tue Dec 29, 2009 7:07 am
by JimFriend
Thanks for the quick reply, mazhar.
I tested out the above code and this is what I found:
First, there are two spots where "options.DefaultUrlPriority = AlwaysConvert.ToDecimal(DefaultUrlPriority.Text);" shows up. It shows up once in GetPostedOptions() and once in initializeControls(). I tried your code in both spots and got this initial error:
'http://www.mydomainhere.com/' is not a valid virtual path.
So instead of using: string path = Server.MapPath(Token.Instance.Store.StoreUrl);
I changed it to: string path = "
http://www.mydomainhere.com";
but I still got an error saying that URI's aren't supported.
Any other ideas?
Re: XML Sitemap being created in wrong directory
Posted: Tue Dec 29, 2009 7:10 am
by mazhar
Give to by changing path to simply "~/"
Re: XML Sitemap being created in wrong directory
Posted: Tue Dec 29, 2009 7:42 am
by JimFriend
I tried changing it to "~/" like you suggested but still got an error.
So I tried hardcoding the path in and it worked correctly. Obviously this isn't ideal because if anything changes or if they move the site it will error, but for now it's working at least.
Re: XML Sitemap being created in wrong directory
Posted: Sat Jan 09, 2010 12:54 pm
by cunningham
Since you have two different databases now, can you change it on Site B?
Code: Select all
SELECT *
FROM ac_StoreSettings
WHERE FieldName = 'CommonSiteMap_SiteMapDataPath'
Re: XML Sitemap being created in wrong directory
Posted: Sat Jan 09, 2010 6:08 pm
by afm
If you have access to the database, delete the value for CommonSiteMap_SiteMapDataPath in the ac_StoreSettings table. Then go to the Site Map page in admin and save the settings (you don't have to change anything). That will force the path to be recalculated.