Forum Discussion

domladden's avatar
9 years ago

Another redirect request

Hi, I want to implement a redirect on a generic blog page back to either the community front page or the parent category page.

 

This is because the category page serves the same content so a blog page without a filter in place will have the same content and therefore possibly create an SEO issue with duplicate pages.

 

ChiaraS kindly pointed out yesterday that we couldn't use a webuisupport request in the PI tab (although one Lithium example here uses this method: http://community.lithium.com/t5/Developers-Knowledge-Base/Using-a-FreeMarker-Page-Initialization-Script/ta-p/125767) but I can't see any other way of achieving this so I tried it on the off chance it might work, it didn't.

 

I want to keep the bg-p if there is either a username or label-name in the URL so I tried this:

 

<#if coreNode.id == "en" >
	<#if page.name == "BlogPage">
		<#if webuisupport.path.parameters.name.get("label-name","") == "">
			<#if webuisupport.path.parameters.name.get("user-id","") == "">
				${http.response.setRedirectUrl(community.urls.frontPage)}
				${http.response.setRedirectStatus(301)}
			</#if>
		</#if>
	</#if>
</#if>

I could separate the label-name and user-id checks into 2 separate redirect requests but I don't think that will make a difference right?

 

Anyone help?

 

Thanks,

 

Dom

  • ChiaraS's avatar
    ChiaraS
    Lithium Alumni (Retired)

    I may be wrong about the webuisupport, that was my assumption looking at the code. It could also be that only some of the webuisupport method work in the init section.

     

    Using nested "if" in your code doesn't look like the right approach... it only triggers if the current node has id "en", current page is BoardPage and (assuming it works) the url path contains "label-name" and "user-id"