Title: Redirect
Last modified: August 21, 2016

---

# Redirect

 *  [ThomasVig](https://wordpress.org/support/users/thomasvig/)
 * (@thomasvig)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/redirect-47/)
 * Hi,
 * I’m trying to build a function which redirect not logged in users:
    If the user
   is not logged in and if the page he/she is trying to reach is not mydomain.com
   then he/she goes to mydomain/welcome
 * Sorry if this is super basic but I am more than a dummy with php…
 * Thanks in advance for your help!
    T

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [C W (VYSO)](https://wordpress.org/support/users/cyril-washbrook/)
 * (@cyril-washbrook)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/redirect-47/#post-4582021)
 * Something like this will probably work, assuming I’ve understood your question:
 *     ```
       <?php
       if( !is_user_logged_in() && !is_front_page() ) :
          wp_redirect( home_url( $path = '/welcome' ) );
       endif;
       ?>
       ```
   
 * If the user is not logged in, and if the current page displayed is not the front
   page, the user is redirected to `{home url}/welcome`.
 *  Thread Starter [ThomasVig](https://wordpress.org/support/users/thomasvig/)
 * (@thomasvig)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/redirect-47/#post-4582234)
 * Hi Cyril,
 * Thanks for your answer! Unfortunately, it does not work. Even if the user goes
   on the front page (www.mydomain.com) it gets redirected to [http://www.mydomain.com/welcome](http://www.mydomain.com/welcome).
 * The next issue is that it does not open the page [http://www.mydomain.com/welcome](http://www.mydomain.com/welcome)
   as there are too many redirects, any idea where it could come from?
 * Thanks again for your help,
    T

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Redirect’ is closed to new replies.

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [ThomasVig](https://wordpress.org/support/users/thomasvig/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/redirect-47/#post-4582234)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
