Try this
function wpse66115_redirect_to_sub_site() {
if ( is_main_site() ) {
if ( is_user_logged_in() ) {
} else {
exit( wp_redirect( 'http://old.heiledeg.no', 301 ) );
}
}
}
add_action( 'parse_request', 'wpse66115_redirect_to_sub_site' );
Related Posts:
- How do I make a redirect in PHP?
- PHP – redirect https to http and www to non-www
- Redirect to Page after Post Submit
- How to redirect users to custom lostpassword page?
- Insert code when users come from an specific referer
- How to turn off redirection from ‘domain.com/login’ to ‘domain.com/wp-login.php’
- Is Auto Post recognition a WordPress feature? How to turn it off?
- WordPress template_include filter not working properly
- Logout and redirect using the WP Menu
- Change links automatically to affiliate links
- PHP If user is logged in & on home page redirect
- Woocommerce redirect thankyou page based on product ID doesn’t empty Cart
- WordPress does not load page.php, return 404.php
- 3 blogs same installation, without WP MU
- WordPress homepage infinite redirect
- Redirect undesirable domain
- How do I display the main domain for my WordPress install?
- Problem with login form
- Set Cache-Control header for 301 redirects
- How to redirect users based on role and content of redirect_to?
- Moving code from theme header to functions.php
- Showing latest post without 301 redirect
- Having Issue on Redirecting With Session in WordPress
- Using a $GET parameter from a URL, to redirect to a URL (WordPress)
- WordPress redirect redirecting too many times or not at all
- Using Argument from Function to Re-Direct Visitor (WordPress)
- I am receiving a pluggable.php warning sign on my only http:// page
- Login redirect. Check user meta and redirect accordingly
- Where to insert redirect code based on http_referer?
- Is this a correct usage of ob_start() in my WordPress project?
- How to allow download url redirection only if user logged in WordPress site?
- PHP Redirect condition
- Manually Create PHP Page For A Redirect
- Redirect to current user page upon link click
- Ajax URLs without #!, how to prevent falling into single.php on load or reload?
- Writing a link cloaking plugin
- WordPress permalink issue
- WP insert post Redirect after function has executed
- How to redirect non logged in mobile users to page on same site?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Download file and redirect to page or vice versa
- Add more user roles to a PHP logout redirect function [closed]
- 404 on old link after changing post url
- WordPress url By country code?
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Implementing a multilingual WordPress site by installing several instances of WordPress and redirecting
- WordPress on Ubuntu – “File not Found” for home.php – Trying to Redirect to Root Folder
- Remove all feeds and return custom 404 page
- Infinite loop when logging out using custom login form
- Redirect User when they click Menu Option
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- wp-login.php?redirect_to=https problem
- ERR_TOO_MANY_REDIRECTS / To Force SSL Logins and SSL Admin Access
- WordPress Redirect / Add_Rewrite_Rule – Non Index.php Page
- Override 404 when navigating to single php file
- Submit to itself don’t work
- redirect 301 with special character like WIX site “#!”
- 301 redirect from webpage to wordpress page in the same root
- Submitting my form to the database and then redirecting to payment site
- 3 domains, 1 wordpress install, redirecting and changing domains on live site
- Get permalink for a post from inside WordPress and route to a related site
- Redirect users not logged in to the standard login page (and back) from some posts and pages
- Link to external page has wordpress blog-url inside
- How to use multiple 404 Error Pages in WordPress
- How to create a WordPress PAGE in another folder?
- index.php file keeps redirecting to a non-existent index.html file?
- Redirect loop upon installation of my plugin
- wp_login_url always redirects me to wp-admin
- Modify previous and next text from pagination links
- Does WordPress cache get_user_meta() results?
- wp_customize_image_control default value
- After upgrading to PHP 7.0 my contact form outputs error
- Get/Set wp.customize.previewer.previewUrl
- Can A Shortcode Get HTML/Text From Content And Return It Twice With Added HTML?
- Do changes to WordPress permalink custom structure affect old urls?
- How do I let users upload files to a chosen location?
- Wp-login appears White Screen, Error: Cannot modify header information
- Creating user status mode in WordPress
- Change “en-US” to “en”
- Code snippet to show current php version inside “At a Glance” box in admin
- getting url from variable that calls picture of current page, not working. Only displays everything instead of url
- Make textarea required. Help [closed]
- How can I use custom menus with a Bootstrap WordPress theme?
- foreach repeat html structure after every nth for attachment [closed]
- In PHP how do I make my navigation bar show certain links to admins only?
- Get current user id in function php
- Proper way to remove html code on child theme
- Display a custom name when the user has no name settle in his account
- Why can’t I connect to the wordpress install page with Nginx?
- Can’t make lazy load for my site, help!
- Noob question: want to remove the “site identity” logo for specific part of website only
- WordPress login with external php script
- How to map my php files as the files for pages
- Property value of null when value is assigned inside a method hooked to the wp action hook
- split searchresults into different topics?
- Simple Probléme in wordpress
- Use HTML Form Data in PHP Function – WordPress Admin Page
- I can’t log into my website , it says “Error: Cookies are blocked due to unexpected output”
- Styling best practices for single pages/templates
- Link on post title only if post have content