feat: robots.txt add sitemap rule (#234)

pull/384/head
Seaton Jiang 2021-05-22 09:08:37 +08:00
parent a1f1e41402
commit e8d1c6fc3a
No known key found for this signature in database
GPG Key ID: C1086BAE716FF138
1 changed files with 4 additions and 2 deletions

View File

@ -3,19 +3,21 @@
* 主题选项
* @author Seaton Jiang <seaton@vtrois.com>
* @license MIT License
* @version 2021.05.18
* @version 2021.05.22
*/
function getrobots()
{
$site_url = parse_url(site_url());
$web_url = get_bloginfo('url');
$path = (!empty($site_url['path'])) ? $site_url['path'] : '';
$robots = "User-agent: *\n\n";
$robots .= "Disallow: $path/wp-admin/\n";
$robots .= "Disallow: $path/wp-includes/\n";
$robots .= "Disallow: $path/wp-content/plugins/\n";
$robots .= "Disallow: $path/wp-content/themes/\n";
$robots .= "Disallow: $path/wp-content/themes/\n\n";
$robots .= "Sitemap: $web_url/wp-sitemap.xml\n";
return $robots;
}