diff options
author | Stan Hu <stanhu@gmail.com> | 2018-08-17 06:51:03 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-08-17 08:11:05 -0700 |
commit | abdd7a52996d6028af2640d18702f1c4fad035c7 (patch) | |
tree | 40fc5829dc0cf2c2ee8b9897fcb1847923b5bed4 | |
parent | 74eec89ebe0b118f8aba6051f53d5dbe5e68c2d1 (diff) | |
download | gitlab-ce-sh-redirect-301-home-page.tar.gz |
Redirect to home page with 301 instead of 302sh-redirect-301-home-page
We noticed a significant drop in Google search results now that Google
is directing all searches to https://gitlab.com.
Closes #50402
-rw-r--r-- | app/controllers/root_controller.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/sh-redirect-301-home-page.yml | 5 | ||||
-rw-r--r-- | spec/controllers/root_controller_spec.rb | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb index 651b82f04f4..f036664062d 100644 --- a/app/controllers/root_controller.rb +++ b/app/controllers/root_controller.rb @@ -23,9 +23,9 @@ class RootController < Dashboard::ProjectsController def redirect_unlogged_user if redirect_to_home_page_url? - redirect_to(Gitlab::CurrentSettings.home_page_url) + redirect_to(Gitlab::CurrentSettings.home_page_url, status: :moved_permanently) else - redirect_to(new_user_session_path) + redirect_to(new_user_session_path, status: :moved_permanently) end end diff --git a/changelogs/unreleased/sh-redirect-301-home-page.yml b/changelogs/unreleased/sh-redirect-301-home-page.yml new file mode 100644 index 00000000000..521ac88578e --- /dev/null +++ b/changelogs/unreleased/sh-redirect-301-home-page.yml @@ -0,0 +1,5 @@ +--- +title: Redirect to home page with 301 instead of 302 +merge_request: 21278 +author: +type: changed diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb index 7688538a468..e317e0482c9 100644 --- a/spec/controllers/root_controller_spec.rb +++ b/spec/controllers/root_controller_spec.rb @@ -7,6 +7,7 @@ describe RootController do get :index expect(response).to redirect_to(new_user_session_path) + expect(response).to have_http_status(301) end context 'when a custom home page URL is defined' do @@ -18,6 +19,7 @@ describe RootController do get :index expect(response).to redirect_to('https://gitlab.com') + expect(response).to have_http_status(301) end end end |