<p>Although it is (as of today) not yet documented, looking through the <a href="http://buildwithcraft.com/classreference/etc/templating/twigextensions/Redirect_TokenParser" rel="nofollow">redirect twig extension</a> revealed that the <a href="http://buildwithcraft.com/docs/templating/redirect" rel="nofollow"><code>redirect</code></a> tag can accept a second parameter for the http status code. So forcing a 301 is done as follows:</p>

<pre><code>{% redirect 'pricing' 301 %}
</code></pre>

<p>I've sent a request to P&amp;T to add this to the docs.</p>

CC BY-SA 3.0
2015-02-19T12:56:04.807Z
2015-02-19T12:56:04.807Z
Ben Croker
<p>Using Craft's <a href="http://buildwithcraft.com/docs/templating/redirect" rel="noreferrer"><code>redirect</code></a> template tag creates a redirect with a 302 (Moved Temporarily) http status code. How can I force a 301 (Moved Permanently) status code?</p>

<templating><redirect><tag>
How do I force a 301 http status code using the redirect tag?
# How do I force a 301 http status code using the redirect tag?

(Asked by: username_0 on 2015-02-19)

Using Craft's [`redirect`](http://buildwithcraft.com/docs/templating/redirect) template tag creates a redirect with a 302 (Moved Temporarily) http status code. How can I force a 301 (Moved Permanently) status code?

**Tags:** templating, redirect, tag

---

## 1 answers

### Answer by username_0 on 2015-02-19. Score: 4

Although it is (as of today) not yet documented, looking through the redirect twig extension revealed that the redirect tag can accept a second parameter for the http status code. So forcing a 301 is done as follows:
{% redirect 'pricing' 301 %}

I've sent a request to P&T to add this to the docs.


---

