How to change WHMCS breadcrumbs portal index page from index.php

In this tutorial we are going to go over how to change or shall we say “fix” the fact that WHMCS DOES NOT allow you to change the “index.php” page for WHMCS portal in the breadcrumbs.  This can be a problem for people who DO NOT want to create a subdirectory or sub folder to put their WHMCS install in.  If you notice on any WHMCS install in the breadcrumbs the “portal” link is set to index.php and it’s not changeable.  This became an issue for me for my new hosting company Host Tornado (http://www.hostt.net) because i have my WHMCS install on my home directory, so if a user is in the customer portal and wants to go back to the index page it takes them to the main page.  Not acceptable. So basically WHMCS is REQUIRING that you create a subdirectory or subfolder, but if you follow the tutorial below i will show you a way to get around that with a little bit of PHP 🙂

Here’s a ticket i submitted to WHMCS asking about this issue and here was their very disappointing reply.

Now I understand that their software in written in PHP and it’s not open source but for the price that i pay for their software it’s kind of ridiculous that they wouldn’t even offer any type of support on this issue.  Besides this issue their software is amazing and i wouldn’t use any other hosting software. So, in order to get the best of both worlds i came up with a simple solution.

So lets get down to business.  The way we are going to “fix” this problem is by using PHP and a couple simple commands.  In order for this to work correctly you MUST have PHP installed on your server and your main homepage MUST be index.php.

So the good thing about PHP is its simplicity, with only a couple lines of code you can create some pretty amazing things.  PHP files can also include any type of HTML you would like and it will work just as if it were an HTML file.  So if you renamed mypage.html to mypage.php it will look EXACTLY the same.

Here’s the full code, i will break it down section by section below.

So let’s start from the beginning and break each section down, this will make it easier to understand how everything is going to work.

With the code above we are using the HTTP_REFERER to find out what page the user is coming from. This is how we will determine if the user is looking for the portal index page or the actual website index page. This will store the website the user came from in the $site string.

The code above checks to see if there is anything in the $site string or not, depending on your PHP configuration you might get an error thrown at your users if for some reason we cannot get the referring website.

The code above we are setting $arr as an array for all the “pages” that the user would be coming from, as you can see i entered all the pages that WHMCS would have a link back to “index.php” on.

Now we are going to go through each each variable in the array to see if there is a match from the referring website. If a match is found the command below these lines above will be executed.

Above is the final piece of code, we are using a header function to redirect the page to portal.php if it is determined that the user came from one of the specified pages above. We also have our closing brackets (}).

This was my version of a work around for this WHMCS issue that they obviously have no intentions of fixing. There are a couple things you need to know before trying to use this code so here’s where you really need to pay attention.

First you must make sure that this code is at the TOP of your index.php file! You CANNOT use the header function to redirect if you have HTML being parsed before this code.

Second, this code was created to be used in a website that implements what i consider the “include” method. I have wrote a tutorial on how to do this (which is very simple) and you can read it here.
http://smyl.es/how-to-create-a-well-structured-website-using-php-and-include-function-1-header-and-footer-file/

You can also change the “array” variables (“submitticket.php” etc) to the entire website (ie “https://www.mysite.com/submitticket.php”) if you want to see if they are coming from an https connection or if you want to make sure that any links to your site that might come from a website with those filenames in the URL will not redirect the user to the wrong page. Unlikely but it doesn’t hurt to change it. Be careful though because it is specific, if you put www.mysite.com/clientarea.php and for some reason your user is coming from http://mysite.com/clientarea.php the script will not work.

Besides that this is a pretty simple PHP code so give it a try and hopefully it will help you out just like it did for me!

Myles

Orlando, FL

Did this post help you?

Give back and rate it for me!

Related Posts

  • Alex

    Hello,
    I started building my website on WordPress then i changed my mind and i edited one of WHMCS’s free templates. My issue now is that i got no idea how to set the WHMCS template that i edited as my homepage. Could you help me?

    • All this tutorial shows is how to change the default index.php file for WHMCS to another file that way you can use another index.php and have WHMCS in the same directory. This tutorial is also pretty old and not even sure if it still works.