<p>Sure, something like this should work (untested):</p>

<pre><code>&lt;a href="{{ currentUser ? url(craft.config.get('postLoginRedirect')) : siteUrl }}"&gt;Home&lt;/a&gt;
</code></pre>

<p>The above should create an absolute URL to whatever's in your <code>postLoginRedirect</code> config setting, relative to your <code>siteUrl</code>.</p>

<p>Note that if you want an URL relative to your Control Panel (e.g. "dashboard"), you'll want to use <code>cpUrl()</code> instead, i.e.</p>

<pre><code>&lt;a href="{{ currentUser ? cpUrl(craft.config.get('postLoginRedirect')) : siteUrl }}"&gt;Home&lt;/a&gt;
</code></pre>

CC BY-SA 3.0
2016-02-17T23:16:45.743Z
Just noticed that with 'postLoginRedirect' => 'dashboard' using the solution above makes the postLoginRedirect a relative link, so it doesn't work on sub-pages. Can you think of a solution besides hard coding an absolute link like 'postLoginRedirect' => '/dashboard'
Keith
CC BY-SA 3.0
2016-02-17T23:22:13.863Z
@Keith You're correct – just updated the answer with a solution.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-02-17T00:21:02.520Z
2016-02-17T23:21:44.477Z
2016-02-17T23:21:44.477Z
Mats Mikkel Rummelhoff
<p>I know I can set  <code>postLoginRedirect</code> in config/general.php to send the user to a specific page after login. Is there a way to grab that value in the template? This came up because I noticed that the <code>{{siteUrl}}</code> href in the default <code>_layout.html</code> template was sending the user to the homepage (index.html), but I'd like to conditionally replace that link for a logged-in user.</p>

<redirect><redirection>
Changing the "homepage" url for logged-in users
# Changing the "homepage" url for logged-in users

(Asked by: username_0 on 2016-02-16)

I know I can set `postLoginRedirect` in config/general.php to send the user to a specific page after login. Is there a way to grab that value in the template? This came up because I noticed that the `{{siteUrl}}` href in the default `_layout.html` template was sending the user to the homepage (index.html), but I'd like to conditionally replace that link for a logged-in user.

**Tags:** redirect, redirection


---

## 1 answers

### Answer by username_1 on 2016-02-17. Score: 3 | Accepted answer

Sure, something like this should work (untested):
Home

The above should create an absolute URL to whatever's in your postLoginRedirect config setting, relative to your siteUrl.
Note that if you want an URL relative to your Control Panel (e.g. "dashboard"), you'll want to use cpUrl() instead, i.e.
Home

> **Comments:**
> **username_0**: Just noticed that with 'postLoginRedirect' => 'dashboard' using the solution above makes the postLoginRedirect a relative link, so it doesn't work on sub-pages. Can you think of a solution besides hard coding an absolute link like 'postLoginRedirect' => '/dashboard'  
> **username_1**: @username_0 You're correct – just updated the answer with a solution.  

---

