title: Spring Security keeps redirecting me to login page
body: <p>What ever link I type in the address bar it keeps redirecting me to the login page. How can I prevent that? </p>
  
  <p>For example if i add <a href="http://localhost:8080/asdasdsa" rel="noreferrer">http://localhost:8080/asdasdsa</a>  > it will redirect me to 
  <a href="http://localhost:8080/account/login" rel="noreferrer">http://localhost:8080/account/login</a>, so if i add anything after <a href="http://localhost:8080/" rel="noreferrer">http://localhost:8080/</a> i will be redirected to account/login view.</p>
  
  <p>My security config:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.example.configuration;
  
  import javax.sql.DataSource;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
  import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  import org.springframework.security.config.annotation.web.builders.WebSecurity;
  import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
  import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
  import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
  import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
  
  @Configuration
  @EnableWebSecurity
  public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
  
      @Autowired
      private BCryptPasswordEncoder bCryptPasswordEncoder;
  
      @Autowired
      private DataSource dataSource;
  
      @Value("${spring.queries.users-query}")
      private String usersQuery;
  
      @Value("${spring.queries.roles-query}")
      private String rolesQuery;
  
      @Override
      protected void configure(AuthenticationManagerBuilder auth)
              throws Exception {
          auth
              .jdbcAuthentication()
                  .usersByUsernameQuery(usersQuery)
                  .authoritiesByUsernameQuery(rolesQuery)
                  .dataSource(dataSource)
                  .passwordEncoder(bCryptPasswordEncoder);
      }
  
      @Override
      protected void configure(HttpSecurity http) throws Exception {
  
          http
              .authorizeRequests()
                  .antMatchers("/").permitAll()
                  .antMatchers("/index").permitAll()
                  .antMatchers("/other/other").permitAll()
                  .antMatchers("/account/login").permitAll()
                  .antMatchers("/account/registration").permitAll()
                  .antMatchers("/account/admin/**").hasAuthority("ADMIN")
                  .anyRequest().authenticated()
                  .and()
              .csrf().disable()
              .formLogin()
                  .loginPage("/account/login")
                  .failureUrl("/account/login?error=true")
                  .defaultSuccessUrl("/account/admin/")
                  .usernameParameter("email")
                  .passwordParameter("password")
                  .and()
              .logout().permitAll()
                  .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
                  .logoutSuccessUrl("/")
                  .and()
              .exceptionHandling()
                  .accessDeniedPage("/access-denied");
      }
  
      @Override
      public void configure(WebSecurity web) throws Exception {
          web
             .ignoring()
                 .antMatchers("/resources/**", "/static/**", "/css/**", "/js/**", "/images/**", "/img/**");
      }
  }
  </code></pre>