Page 1 of 1

Change default landing page

Posted: Fri Oct 21, 2016 9:22 am
by SavaSC
Hello,

The default URL for nagiosxi is http://ServerName/NagiosXI. Unfortunately, that means that if you just go to http://ServerName that you then have to click on a link to take you to the \NagiosXI page. Is there any way to redirect traffic directly to the /NagiosXI page? I know how to do this with IIS but not with Apache.

Thanks!

Re: Change default landing page

Posted: Fri Oct 21, 2016 9:46 am
by bwallace
This doc will show how to change the landing page:
https://assets.nagios.com/downloads/nag ... g-Page.pdf

Re: Change default landing page

Posted: Fri Oct 21, 2016 12:50 pm
by SavaSC
Thank you for your response, but this is not the information I was looking for. I was trying to make it where people were automatically redirected to the log-in page instead of the "click here to get to the log-in page" page. The document you referenced tells how to change what page shows up after a user logs on. I was referring to before they log on.

Incidentally, I figured it out. You have to edit the following file:
/var/www/html/index.php

Somewhere in there (I put it in the header) stick the following code:

Code: Select all

	<?php
	header("Location: http://ServerName.YourCompany.com/nagiosxi/");
	?>
BOOM! No more having to click twice to get to the login page.

This question has been answered. You can close this thread.

Re: Change default landing page

Posted: Fri Oct 21, 2016 1:25 pm
by rkennedy
This will work, but index.php will be overwritten when you update.

I would rewrite this at an apache level rather then PHP, by doing the following:

Modify /etc/httpd/conf.d/nagiosxi.conf and look for -

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
</IfModule>
Before the </IfModule>, add this -

Code: Select all

RedirectMatch ^/$ /nagiosxi/
Then restart httpd, and it will redirect / to /nagiosxi/.

Re: Change default landing page

Posted: Fri Oct 21, 2016 7:34 pm
by gormank
Home Page Modification in admin manage components seems to be what you're looking for. The http://<nagios fqdn> leads to a page where you click a link to log in. http://<nagios fqdn>/nagiosxi leads to the page defined in components or a login prompt.

Re: Change default landing page

Posted: Mon Oct 24, 2016 11:27 am
by rkennedy
Thanks @gormank!

@SavaSC - let us know if you have any further questions.

Re: Change default landing page

Posted: Fri Oct 28, 2016 10:17 am
by SavaSC
gormank wrote:Home Page Modification in admin manage components seems to be what you're looking for. The http://<nagios fqdn> leads to a page where you click a link to log in. http://<nagios fqdn>/nagiosxi leads to the page defined in components or a login prompt.


Unless there is something I'm missing, this doesn't do what I am requesting. This is for after a user logs in, not before.

Re: Change default landing page

Posted: Fri Oct 28, 2016 10:21 am
by SavaSC
rkennedy wrote:This will work, but index.php will be overwritten when you update.

I would rewrite this at an apache level rather then PHP, by doing the following:

Modify /etc/httpd/conf.d/nagiosxi.conf and look for -

Code: Select all

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule nagiosxi/api/v1/(.*)$ /usr/local/nagiosxi/html/api/v1/index.php?request=$1 [QSA,NC,L]
</IfModule>
Before the </IfModule>, add this -

Code: Select all

RedirectMatch ^/$ /nagiosxi/

Then restart httpd, and it will redirect / to /nagiosxi/.
This worked! Thank you so much!

Re: Change default landing page

Posted: Fri Oct 28, 2016 12:57 pm
by mcapra
Is it alright if we lock this thread and mark the issue as resolved, or did you need additional assistance with the landing page configuration?

Re: Change default landing page

Posted: Fri Oct 28, 2016 1:08 pm
by SavaSC
You can lock it. Thank you for the assistance.