MyBB Community Forums

Full Version: Direct all traffic except admin to a different landing page?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
What is the best way to redirect all traffic the admin to a certain landing page for example a coming soon page? ThanksĀ  Big Grin
Best way would be to use something like this https://www.siteground.com/kb/how_to_red...ther_site/
I think a plugin hooks global_start should be able to do that job.
(2019-10-13, 12:12 PM)Ben Wrote: [ -> ]Best way would be to use something like this https://www.siteground.com/kb/how_to_red...ther_site/

I am using nginx so I may need another option (there is no .htaccess in my server)

(2019-10-13, 01:51 PM)noyle Wrote: [ -> ]I think a plugin hooks global_start should be able to do that job.

Not entirely sure how to start doing that honestly
You need to edit the nginx configuration either for "server" or a specific "location" stanza, like this
server {
if (%{$remote_addr !~ "^1.2.3.4"){
	rewrite /.* http://www.example.com redirect;
}
or
location / {
if (%{$remote_addr !~ "^1.2.3.4"){
	rewrite /.* http://www.example.com redirect;
}
or
... { rewrite ^/$ http://www.example.com redirect; }

Find a lot of examples in the net by searching for nginx rewrite.

[ExiTuS]
(2019-10-14, 09:26 AM)[ExiTuS] Wrote: [ -> ]You need to edit the nginx configuration either for "server" or a specific "location" stanza, like this
server {
if (%{$remote_addr !~ "^1.2.3.4"){
	rewrite /.* http://www.example.com redirect;
}
or
location / {
if (%{$remote_addr !~ "^1.2.3.4"){
	rewrite /.* http://www.example.com redirect;
}
or
... { rewrite ^/$ http://www.example.com redirect; }

Find a lot of examples in the net by searching for nginx rewrite.

[ExiTuS]

Unfortunately neither of those work properly for me, and I receive an error after replacing the IP and domain. Is there further modification required other than that?
Stupid question, why don't use https://community.mybb.com/mods.php?action=view&pid=474 ? With good settings, it could work for your needs.
(2019-10-14, 11:27 AM)Crazycat Wrote: [ -> ]Stupid question, why don't use https://community.mybb.com/mods.php?action=view&pid=474 ? With good settings, it could work for your needs.

Hmm I don't think that'd be the best way to do it, and honestly I think there is an easier way to do it like Exitus and Ben showed but maybe a problem with the code or something which is why I cant get it to work with my website
For performance purpose, it is the best way to do a redirect on a lower level, so webserver.

Sorry, if my example config code does not work well - because of a syntax slip. I am not well familiar with this webserver. So do not copy/paste the code but take it as an inspiration on how to do such on nginx.

[ExiTuS]