Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to apply redirection for entire space

Abraham Toribio June 10, 2019

We recently created a new space by cloning an old space. The new space has a new spacekey, obviously.

My problem is, the old spacekey is still showing up in searches like Google. What I want to do is when users click the old spacekey from the search result, they will be redirected to the new space. Is there a way to do this en mass for the entire space? I know we can use the redirect plugin for a page, but I don't wanna create a redirect for each and every page of the  entire space.

I've also tried blocking the old space from public view, but then it still shows up in Google searches.

2 answers

1 accepted

1 vote
Answer accepted
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 12, 2019

Hello Abraham,

If you’re wanting to take users who navigate to a ‘page” from google and send them to a new ‘page’ or space within Confluence then you’ll need to use javascript customization within your old space to forward/redirect your users to the new space. Stephen Brannen wrote up an answer previously about doing this which should still be applicable now. You may find this post at How to apply redirection on all pages on a space? Within there the following is referenced:

You will want to paste the following into the 'At the end of the HEAD' section of the Custom HTML section of the Confluence Administration screen.

<script type="text/javascript">
 function Redirect(newUrl, path) {
  window.location = newUrl + path;
 }
 space = "TEST";
 if (space == AJS.params.spaceKey) {
  var newUrl = "http://new.confluence.com"
  var path = window.location.pathname;
  Redirect(newUrl, path);
 }
</script>

If you would prefer to warn users, you could use an Alert and set a timeout like below:

<script type="text/javascript">
 function Redirect(newUrl, path) {
  window.location = newUrl + path;
 }
 space = "TEST";
 if (space == AJS.params.spaceKey) {
  var newUrl = "http://new.confluence.com"
  var path = window.location.pathname;
  alert("You will be redirected to the new page location in 3 seconds.");
  setTimeout('Redirect(newUrl, path)', 3000);
 }
</script>

Please let us know if this example works for your needs and assist with redirecting traffic from your old Confluence space to the new space.

Regards,
Stephen Sifers

Abraham Toribio June 12, 2019

Hi Stephen,

We made a couple of tweaks and then it worked! Thanks very much!

Like Stephen Sifers likes this
0 votes
Stavros_Rougas_EasyApps
Atlassian Partner
October 4, 2023

If like many server clients you have moved to cloud you will discover what Stephan suggests is impossible. You don't have that level of customization in cloud.

We built a redirection app called Redirection by Easy Apps and learned all about what can and cannot be done in cloud. What can be done is not technically a redirect. But you do not need any technical knowledge to use it, it's built to that marketing and a cross section of team members can use it.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events