Jump to content

Need to rewrite/redirect WHMCS index.php


Troy

Recommended Posts

I recently upgraded to WHMCS 7.4.2, from (believe it or not) 5.3.14.

Looks like URLs are handled a bit differently, and I'm having trouble with a rewrite I need to do.

Basically I want to suppress WHMCS's index.php. I've decided to keep everything in the root, marketing pages that are html and WHMCS php files. There are no collisions and everything is working fine except that I don't ever want people using the WHMCS home page--I want it to redirect to the html homepage. (Client area links outside of WHMCS will all link to clientarea.php and force login if not already logged in.)

Problem is, it appears that URLs now route through index.php to an extent. I definitely want to retain full friendly URLs. However, if a request comes in for just the home page index.php, I want it to redirect to index.html.

Anything I've tried that actually redirects index.php if it has no query string variables will also redirect the knowledgebase, which I don't want to happen. So far it seems like only the knowledgebase is affected.

Has anyone accomplished something similar and could pass along any pointers. I've tried some many rewrite rule variations but can't seem to get it working properly.

Edited by Troy
Link to comment
Share on other sites

18 hours ago, Troy said:

Has anyone accomplished something similar and could pass along any pointers. I've tried some many rewrite rule variations but can't seem to get it working properly.

you should be able to do it using an action hook, so that if anyone visits the homepage, then they are redirected to another URL - other pages that can use index.php (announcements, kb etc) shouldn't be affected.

<?php

function homepage_redirect_to_url_hook($vars)
{
    if ($vars['templatefile']=="homepage"){
        header("Location: http://www.bbc.co.uk/news");
        exit;
    }
}
add_hook("ClientAreaPageHome", 1, "homepage_redirect_to_url_hook");

obviously, don't use the BBC news page for the redirect (that might confuse the hell out of your clients!), point it back to your html page - if it's in the same path as index.php, then you shouldn't need to use the full URL, just the filename, e.g index.html or whatever.

Link to comment
Share on other sites

Awesome idea, thanks! I hadn’t thought of using a hook. Kinda dumb of me since I did use a hook to change the destination of the whmcs home menu item.

I’ll give this a try and report back. 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated