# Page Redirection

**URL:** <https://community.hubspot.com/t/page-redirection/57862>\
**Category:** CMS Development\
**Tags:** forms\
**Created:** [May 27, 2022, 12:45pm UTC](https://community.hubspot.com/t/page-redirection/57862 "2022-05-27T12:45:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![VYadav7](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@VYadav7](https://community.hubspot.com/u/VYadav7)\
**Post date:** [May 27, 2022, 12:45pm UTC](https://community.hubspot.com/t/page-redirection/57862/1 "2022-05-27T12:45:55Z")

</div>

this url is not redirecting to respective url please help me out

\<div class=“container” id=“tab3C”\>  
\<div class=“portfoliolist” id=“whitepapers\_portfoliolist”\>  
{% for row in hubdb\_table\_rows(5311014, “status=Published&orderBy=-hs\_created\_at”) %}  
{% set sentence\_whitepapers\_title = row.whitepapers\_title %}  
{% set sentence\_all\_offerings = row.all\_offerings %}  
{% set sentence\_all\_industry = row.all\_industry %}  
\<div class=“whitepapers-hide mix portfolio all-offerings all-industry {{sentence\_all\_offerings.name|lower|replace(’ ‘, ‘-’)|replace(’ ‘, ‘’)}} {{ sentence\_all\_industry.name|lower|replace(’ ‘, ‘-’)|replace(’-&-', ‘-’)}} {{ sentence\_whitepapers\_title|lower }}” data-filter-item data-filter-name=“{{ sentence\_whitepapers\_title|lower }}”\>  
\<div class=“portfolio-wrapper”\>  
{% if row.whitepapers\_image %}  
\<img src=“{{ row.whitepapers\_image.url }}” alt=“{{ row.whitepapers\_title }}”\>  
{% else %}  
\<img src=“{{ get\_asset\_url(‘../images/resources-image.png’) }}” alt=“Image” /\>  
{% endif %}  
\<div class=“label”\>  
\<div class=“label-text”\>  
\<div class=“text-title match”\>{{ row.whitepapers\_title|truncatehtml(80, ‘…’ , false) }}\</div\>  
\<div class=“text-description”\>{{ row.whitepapers\_description|truncatehtml(90, ‘…’ , false) }}\</div\>  
\<div class=“view-link”\>  
{% if row.is\_it\_gated.name== ‘Yes’ %}  
\<a href=“{{ domain }}/download-whitepapers/?redirect={{ domain }}/whitepapers/{{ row.hs\_path }}” class=“text-link gettedform” target=“\_blank”\>Download\</a\>  
{% else %}  
\<a href=“{{ domain }}/whitepapers/{{ row.hs\_path }}” class=“text-link” target=“\_blank”\>Download\</a\>  
{% endif %}  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
\</div\>  
{% endfor %}  
\<div class=“load-more-button” style=“display: none;”\>  
\<a href=“javascript:void(0)” class=“whitepaper-load-more button”\>Load More\</a\>  
\</div\>  
\</div\>  
\</div\>

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [May 30, 2022, 11:44pm UTC](https://community.hubspot.com/t/page-redirection/57862/2 "2022-05-30T23:44:34Z")

</div>

@piersg , what are you thoughts on this redirect mayhem? 😎

---

<div class="post-metadata">

**Author:** ![piersg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/piersg/32/99782_2.png) [@piersg](https://community.hubspot.com/u/piersg)\
**Post date:** [May 31, 2022, 10:36am UTC](https://community.hubspot.com/t/page-redirection/57862/3 "2022-05-31T10:36:39Z")

</div>

Have you set {{ domain }} somewhere in your code that you haven’t copy pasted here? If not, it’s not a valid HubL variable, you need {{ request.domain }} and you need to add the protocol to it, e.g.

`href="https://{{ request.domain }}/download-whitepapers?redirect={{ request.domain }}/whitepapers/{{ row.hs_path }}"`

Are you reading the “?redirect” url parameter with JS and doing something with it based on some event e.g. form submission?

---

<div class="post-metadata">

**Author:** ![VYadav7](https://avatars.discourse-cdn.com/v4/letter/v/8c91f0/32.png) [@VYadav7](https://community.hubspot.com/u/VYadav7)\
**Post date:** [June 29, 2022, 11:46am UTC](https://community.hubspot.com/t/page-redirection/57862/4 "2022-06-29T11:46:15Z")

</div>

I have used this code and it works fine

\<script\>  
hbspt.forms.create({  
region: “na1”,  
portalId: “2466330”,  
formId: “{{ module.download\_assets\_form\_id }}”,  
inlineMessage: ‘This page is redirecting…’,  
onFormSubmit: function($form){  
setTimeout( function() {  
window.location = “{{ request.query\_dict.redirect }}”;  
}, 250 );  
}  
});  
\</script\>
