Rewrite URL to routing URL I have created a routing URL like 

login.compnay_login_form:
  path: '/u/{company_name}/login'
  defaults:
    _controller: '\Drupal\login\Controller\LoginController::login_form'
    _title: 'Login'
  requirements:
    _permission: 'access content


This works with http://example.com/u/testcompany/login

But I want the URL like http://example.com/testcompany/login for that I write the below routing 

login.compnay_login_form:
  path: '/{company_name}/login'
  defaults:
    _controller: '\Drupal\login\Controller\LoginController::login_form'
    _title: 'Login'
  requirements:
    _permission: 'access content'


but it's not working.  

Please let me know if any other way to achieve this.

http://example.com/testcompany/login 

should call to  

http://example.com/u/testcompany/login

may be through htaccess or any other way?
If there is a node for each company, you can insert an alias when the node is saved.  Set up the alias created for each company to start with '/company/{company_name}', then when the alias is inserted, you can add a secondary alias for login:

/**
 * Implements hook__path_insert().
 */
function mymodule_path_insert($path) {
  if (preg_match('/company\/(.*)/', '/company/xyz', $matches) &amp;&amp; preg_match('/node\/(\d+)$/', $path['source'])) {
  $company_name = $matches[1];
    \Drupal::service('path.alias_storage')-&gt;save("/u/$company_name/login", "$company_name/login" $path['langcode']);
  }
}


This way, the visible path will be /{company_name}/login, but the machine name as far as Drupal is concerned with be /u/{company_name}/login.

You could instead do this on entity_insert and entity_update.