Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong rules in robots.txt #9462

Merged
merged 4 commits into from Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions classes/Tools.php
Expand Up @@ -2566,7 +2566,7 @@ public static function generateRobotsFile($executeHook = false)
if (count($robots_content['Directories'])) {
fwrite($write_fd, "# Directories\n");
foreach ($robots_content['Directories'] as $dir) {
fwrite($write_fd, 'Disallow: */'.$dir."\n");
fwrite($write_fd, 'Disallow: /'.$dir."\n");
}
}

Expand Down Expand Up @@ -2621,22 +2621,22 @@ public static function getRobotsContent()
'*/modules/*.js',
'*/modules/*.png',
'*/modules/*.jpg',
'*/themes/*/assets/cache/*.js',
'*/themes/*/assets/cache/*.css',
'*/themes/*/assets/css/*',
'/js/jquery/*',
);

// Directories
$tab['Directories'] = array('cache/', 'classes/', 'config/', 'controllers/',
'css/', 'download/', 'js/', 'localization/', 'log/', 'mails/', 'modules/', 'override/',
'pdf/', 'src/', 'tools/', 'translations/', 'upload/', 'vendor/', 'web/', 'webservice/');
$tab['Directories'] = array(
'app/', 'cache/', 'classes/', 'config/', 'controllers/',
'download/', 'js/', 'localization/', 'log/', 'mails/', 'modules/', 'override/',
'pdf/', 'src/', 'tools/', 'translations/', 'upload/', 'var/', 'vendor/', 'webservice/',
);

// Files
$disallow_controllers = array(
'addresses', 'address', 'authentication', 'cart', 'discount', 'footer',
'get-file', 'header', 'history', 'identity', 'images.inc', 'init', 'my-account', 'order',
'order-slip', 'order-detail', 'order-follow', 'order-return', 'order-confirmation', 'pagination', 'password',
'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'product-sort', 'search', 'statistics','attachment', 'guest-tracking'
'pdf-invoice', 'pdf-order-return', 'pdf-order-slip', 'product-sort', 'search', 'statistics', 'attachment', 'guest-tracking',
);

// Rewrite files
Expand Down
11 changes: 10 additions & 1 deletion controllers/admin/AdminMetaController.php
Expand Up @@ -37,6 +37,16 @@ class AdminMetaControllerCore extends AdminController
protected $url = false;
protected $toolbar_scroll = false;

/**
* @var string Path to .htaccess
*/
private $ht_file;

/**
* @var string Path to robots.txt
*/
private $rb_file;

public function __construct()
{
$this->table = 'meta';
Expand All @@ -46,7 +56,6 @@ public function __construct()
$this->identifier_name = 'page';
$this->ht_file = _PS_ROOT_DIR_.'/.htaccess';
$this->rb_file = _PS_ROOT_DIR_.'/robots.txt';
$this->rb_data = Tools::getRobotsContent();

parent::__construct();

Expand Down
41 changes: 21 additions & 20 deletions robots.txt
Expand Up @@ -12,6 +12,7 @@ Allow: */modules/*.css
Allow: */modules/*.js
Allow: */modules/*.png
Allow: */modules/*.jpg
Allow: /js/jquery/*
# Private pages
Disallow: /*?order=
Disallow: /*?tag=
Expand Down Expand Up @@ -55,26 +56,26 @@ Disallow: /*controller=statistics
Disallow: /*controller=attachment
Disallow: /*controller=guest-tracking
# Directories
Disallow: */cache/
Disallow: */classes/
Disallow: */config/
Disallow: */controllers/
Disallow: */css/
Disallow: */download/
Disallow: */js/
Disallow: */localization/
Disallow: */log/
Disallow: */mails/
Disallow: */modules/
Disallow: */override/
Disallow: */pdf/
Disallow: */src/
Disallow: */tools/
Disallow: */translations/
Disallow: */upload/
Disallow: */vendor/
Disallow: */web/
Disallow: */webservice/
Disallow: /app/
Disallow: /cache/
Disallow: /classes/
Disallow: /config/
Disallow: /controllers/
Disallow: /download/
Disallow: /js/
Disallow: /localization/
Disallow: /log/
Disallow: /mails/
Disallow: /modules/
Disallow: /override/
Disallow: /pdf/
Disallow: /src/
Disallow: /tools/
Disallow: /translations/
Disallow: /upload/
Disallow: /var/
Disallow: /vendor/
Disallow: /webservice/
# Files
Disallow: /password-recovery
Disallow: /address
Expand Down