Answers.Body: <p>OK, no one answered....I have to take another way to do which is to put a piece of code like this into user-profile page</p>
  
  <pre><code>{% if not currentUser %}
    {% redirect '/' %}
  {% endif %}
  </code></pre>
  
  <p>and take out <code>loginPath</code> setting in config file.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-22T21:01:30.370Z
Answers.Text: Do you have a requireLogin tag on the homepage - the template behind the url you are routing to? What redirecting to the / does is redirect to the homepage. If you have a requireLogin tag on this page your routing will go haywire in an infinite loop.
Answers.UserDisplayName: Gįëł Tėttëłæår
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-23T01:24:05.607Z
Answers.Text: @GįëłTėttëłæår no, it doesn't make any sense to make homepage login-required. And that's why I got confused. There's no requireLogin tag on homepage, why it keeps looping
Answers.UserDisplayName: yu xia
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-22T20:14:35.263Z
Answers.LastActivityDate: 2018-03-22T20:14:35.263Z
Answers.UserDisplayName: yu xia
Body: <p>I made a modal for login at homepage and put <code>{%requireLogin%}</code> tag in "User Profile" page.
  My <code>general.php</code> file looks like below:</p>
  
  <pre><code>'dev' =&gt; [
          // Base site URL
          'siteUrl' =&gt; null,
  
          // Dev Mode (see https://craftcms.com/support/dev-mode)
          'devMode' =&gt; true,
          'loginPath' =&gt; '/',
      ],
  </code></pre>
  
  <p>I hope to prevent users to go to "User Profile" page without login and redirect them to homepage. But the issue is when I login on the homepage, the browser gives an error <code>redirected you too many times.</code></p>
  
  <p>Any idea how to do that please? Many thanks!!</p>
  
Tags: <redirect><login><redirection>
Title: how to set loginPath in config file
ThreadText: # how to set loginPath in config file
  
  (Asked by: username_0 on 2018-03-21)
  
  I made a modal for login at homepage and put `{%requireLogin%}` tag in "User Profile" page.
  My `general.php` file looks like below:
  
  ```
  'dev' => [
          // Base site URL
          'siteUrl' => null,
  
          // Dev Mode (see https://craftcms.com/support/dev-mode)
          'devMode' => true,
          'loginPath' => '/',
      ],
  
  ```
  
  I hope to prevent users to go to "User Profile" page without login and redirect them to homepage. But the issue is when I login on the homepage, the browser gives an error `redirected you too many times.`
  
  Any idea how to do that please? Many thanks!!
  
  **Tags:** redirect, login, redirection
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-03-22. Score: 1
  
  OK, no one answered....I have to take another way to do which is to put a piece of code like this into user-profile page
  
  ```
  {% if not currentUser %}
    {% redirect '/' %}
  {% endif %}
  
  ```
  
  and take out `loginPath` setting in config file.
  
  > **Comments:**
  > **username_1**: Do you have a requireLogin tag on the homepage - the template behind the url you are routing to? What redirecting to the / does is redirect to the homepage. If you have a requireLogin tag on this page your routing will go haywire in an infinite loop.  
  > **username_0**: @username_1 no, it doesn't make any sense to make homepage login-required. And that's why I got confused. There's no requireLogin tag on homepage, why it keeps looping  
  
  ---
  
  