if (mb_strpos($_SERVER['REQUEST_URI'], '/product-category/') !== false) {
global $wp_query;
$category = get_queried_object();
if ($category->term_id) {
if ($_SERVER['REQUEST_URI'] != str_replace('http://localhost', '', get_term_link($category->term_id))) {
$wp_query->set_404();
status_header(404);
}
}
}