I want change all /user, /user/* urls by /profile, /profile/* urls. From a custom module, I copied all user routes (found in /core/module/user/user.routing.yml) to my custom .routing.yml file. I replaced all "user*" paths by "profile*".
Now, I have the following.
mycustommodule.register:
path: '/profile/register'
defaults:
_entity_form: 'user.register'
_title: 'Create new account'
requirements:
_access_user_register: 'TRUE'
mycustommodule.pass:
path: '/profile/password'
defaults:
_form: '\Drupal\user\Form\UserPasswordForm'
_title: 'Reset your password'
requirements:
_access: 'TRUE'
options:
_maintenance_access: TRUE
mycustommodule.page:
path: '/profile'
defaults:
_controller: '\Drupal\user\Controller\UserController::userPage'
_title: 'My account'
requirements:
_user_is_logged_in: 'TRUE'
mycustommodule.login:
path: '/profile/login'
defaults:
_form: '\Drupal\user\Form\UserLoginForm'
_title: 'Log in'
requirements:
_user_is_logged_in: 'FALSE'
options:
_maintenance_access: TRUE
mycustommodule.login.http:
path: '/profile/login'
defaults:
_controller: \Drupal\user\Controller\UserAuthenticationController::login
methods: [POST]
requirements:
_user_is_logged_in: 'FALSE'
_format: 'json'
mycustommodule.login_status.http:
path: '/profile/login_status'
defaults:
_controller: \Drupal\user\Controller\UserAuthenticationController::loginStatus
methods: [GET]
requirements:
_access: 'TRUE'
_format: 'json'
mycustommodule.logout.http:
path: '/profile/logout'
defaults:
_controller: \Drupal\user\Controller\UserAuthenticationController::logout
methods: [POST]
requirements:
_user_is_logged_in: 'TRUE'
_format: 'json'
_csrf_token: 'TRUE'
mycustommodule.cancel_confirm:
path: '/profile/{user}/cancel/confirm/{timestamp}/{hashed_pass}'
defaults:
_title: 'Confirm account cancellation'
_controller: '\Drupal\user\Controller\UserController::confirmCancel'
timestamp: 0
hashed_pass: ''
requirements:
_entity_access: 'user.delete'
user: \d+
mycustommodule.reset.login:
path: '/profile/reset/{uid}/{timestamp}/{hash}/login'
defaults:
_controller: '\Drupal\user\Controller\UserController::resetPassLogin'
_title: 'Reset password'
requirements:
_user_is_logged_in: 'FALSE'
options:
_maintenance_access: TRUE
no_cache: TRUE
mycustommodule.reset:
path: '/profile/reset/{uid}/{timestamp}/{hash}'
defaults:
_controller: '\Drupal\user\Controller\UserController::resetPass'
_title: 'Reset password'
requirements:
_access: 'TRUE'
options:
_maintenance_access: TRUE
no_cache: TRUE
mycustommodule.reset.form:
path: '/profile/reset/{uid}'
defaults:
_controller: '\Drupal\user\Controller\UserController::getResetPassForm'
_title: 'Reset password'
requirements:
_user_is_logged_in: 'FALSE'
options:
_maintenance_access: TRUE
no_cache: TRUE
From my website, when I go to the http://mysite/profile, I'm redirected to the correct page (the user view), but the URL change automatically to http://mysite/user. I want keep the URL as http://mysite/profile. How can I do that? Is it possible?