How to apply redirection on all pages on a space?

Hi All

Ihave recently migrated a confluence space from Server A to B.

I want to be able to get users to automatically get redirected from all pages on the migrated space on Server A to Server B.

I am aware of the redirection plugin but you have to apply it on each and every page manually.

Are there any easier options? Plugins? workarounds?

Rahul

1 answer

0 vote

Hey Rahul,

I'm not sure of a plugin that would easily allow this, but it is something you could accomplish using JavaScript. The following will redirect any users accessing a page on the specified space on Server A to the same page on Server B. 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>

To use this, simply edit 'space' to the space key of the space you want this to run in. Also, set the newUrl variable to the hostname of the new Confluence server.

Stephen

This is awesome. I couldn't get the variation with the Alert to work, but version 1 solved a huge issue I had. Thank you!

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

850 views 23 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you