latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Redirect From Subdomain to Domain

Home Forums Community Forum Redirect From Subdomain to Domain

This topic contains 1 reply, has 2 voices. Last updated by  Randy King 3 years, 11 months ago.

Topic Author Topic
Posted: Monday Jan 21st, 2013 at 3:54 pm #38626

When someone attempts to access a page on a subdomain of my site I would like that visitor to be directed to the main domain homepage where I have information on signing up for the site and my payment buttons.

When I go to the membership options page settings in the subdomain I can only choose a page within that subdomain to direct logged out visitors.

Is there a way to direct visitors to the main domain homepage no matter what subdomain they attempt to access?

I am running a multisite installation of WordPress.

List Of Topic Replies

Viewing 1 replies (of 1 total)
Author Replies
Author Replies
Posted: Monday Jan 21st, 2013 at 4:07 pm #38633
Randy King
Username: RandyKing

Keith,

If you’re looking to do this all the time; i.e., there is no content on the sub-domain page that you ever want to display, then use a re-director plugin attached to that page to do the work for you.

I use a plugin called “Quick Page/Post Redirect Plugin” by Don Fischer to do this.

Once you activate that plugin in the sub-domain site, go to the page that you want to have re-directed and near the bottom tick the “Make Redirect Active” checkbox, enter the “Redirect URL” in the box provided, then set the redirection type to its default, which is 302 (Temporary).

Don’t be confused by the latter setting – a “302 redirect” is what you want, even though your re-direct is permanent. This is because you don’t want search engines permanently storing the new re-directed URL. You want them coming through your sub-domain so that any future changes to your re-direct will continue to work.

HOWEVER, if the sub-domain has legitimate stuff on it that you do want accessed by members, you won’t want to use a re-director plugin. Instead, you can use S2Member shortcodes with a script to accomplish this:

[s2If is_user_logged_in() ]
	<<..stuff that you want to do for logged-in members..>>
[/s2If]

[s2If !is_user_logged_in() ]
	<script type="text/javascript">
		window.location = 'http://www.MyMainDomain.com/';
	</script>
[/s2If]

Consequently, if someone reaching that page IS logged in, they will be presented with the stuff that’s inside the “is_user_logged_in” block, otherwise they will be re-directed to the main domain page.

Note – you should be working in the HTML editor, NOT the visual editor. I frequently just disable the visual editor inside of my WordPress user profile.

  • This reply was modified 3 years, 11 months ago by  Randy King.
Viewing 1 replies (of 1 total)

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.