i have a plugin that create the sitemap.xml file for my website and if i run that from cron hourly it is creating the sitemap file with entries like http:///sitemap_subs.xml.gz Code (markup): ..... it is actually missing the baseurl. but if i run that from my website it create correctly with my base url help me to run from my cron , do i have to run it as appache user if so please give me the cron statement example[/code]
any help experts, i have to run the php every one hour, so if i run it through cron it will do the job is ease........so please anyone any hint to solve
Is it a Wordpress website? Can you please explain what you meant by this? If you mean that, the your PHP code in a particular file works when accessed directly? Say for example, the PHP file is: http://www.mysite.com/gen.php When accessed, it is generating the sitemap files? In that case, just add a cron job in your cPanel to run that file, every hour! The command would be like this: /usr/bin/php -q /home/your_username/public_html/mysite.om/gen.php Here's the screenshot: Hope it helps! Otherwise, please provide some more information so that we could share a better solution. Thank you
yes i did the same /usr/bin/php -q /home/your_username/public_html/mysite.om/gen.php but when running from cron the output sitemap if run from cron is like http:///sitemap.xml the website name is missing, it should be like http://domain.com/sitemap.xml Code (markup):
I think that's path related issue. Check your code. Try defining a constant to store the base url and append it while generating the sitemap url data. Example: define('BASEURL', 'http://domain.com'); // your website base address //--------- while generating the sitemap data... echo BASEURL . '/index.php'; echo BASEURL . '/contact.php'; //...etc.. PHP: See if it works.
my domain have sub domain so will setting only the main domain is enough or i have enter all the sub domains
You mean you are trying to include both the main domain's as well as subdomain's content in a single sitemap file? I think that wouldn't be a good choice! Have a look at this: https://webmasters.stackexchange.com/questions/82687/sitemaps-one-per-subdomain-or-one-for-the-base-domain I believe each base domain and subdomain has its own sitemap. That being said, if you want to include subdomain content in the code for creating sitemap file, just define that as a constant too. Example: define('BASEURL', 'http://domain.com'); // your website base address define('SUBDOMAINURL', 'http://abc.domain.com'); // your subdomain address PHP: Then use these constants while creating the links! Hope it helps.