NadalKumar Posted April 28, 2019 Share Posted April 28, 2019 I have developed a functional routing system to convert URLS to SEF but WHMCS seems to have a built in method that requires filename index.php to be included in the URL, otherwise it redirects to 404 error, even with the system Friendly Urls setting at Full Sef. How can that method be overridden? The htaccess is configured to remove index.php from the url RewriteCond %{REQUEST_URI} !^/index\.php RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule .* index.php [QSA,L] and the router class alters the menu urls eg: index.php?component=posts&view=post&category=1-uncategorized&post=12-end-user-license-agreement&menuid=9 is converted to site.com/whmcs-license where whmcs-license is the alias of the menu item as stored in the database. It works correctly to display the page content, however it's calling the display file within error/page-not-found.tpl I've tried using Smarty ->assign(['templatefile' => 'component']); to use the component.tpl file when in the scope of any element of the url query but WHMCS still seeks index.php, though showing that the current file is indeed component.tpl. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 28, 2019 Share Posted April 28, 2019 10 hours ago, NadalKumar said: How can that method be overridden? if you ever find the answer to that question, do let the rest of us know! 🙂 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted April 28, 2019 Share Posted April 28, 2019 No you can't. WHMCS has encoded file names and links behind PHP classes that are encoded now. .htaccess is only going to get you so far before you need to start developing PHP code that tries to overwrite the WHMCS default routes, even that will not work completely since some pages have POST requests on forms that are passed directly to WHMCS and they then try to redirect back to their own filenames which means your .htaccess rules will be very much useless for that. To resume. You cannot use SEO url's or customer filenames/links with WHMCS anymore, starting with version 7 as they removed code from templates and put them behind routing classes. You will find out that most internal functions will default to the error page once they cannot find the file. My advise is not to use the SEO settings at all because its completely broken. 0 Quote Link to comment Share on other sites More sharing options...
NadalKumar Posted April 28, 2019 Author Share Posted April 28, 2019 44 minutes ago, yggdrasil said: No you can't. WHMCS has encoded file names and links behind PHP classes that are encoded now. .htaccess is only going to get you so far before you need to start developing PHP code that tries to overwrite the WHMCS default routes, even that will not work completely since some pages have POST requests on forms that are passed directly to WHMCS and they then try to redirect back to their own filenames which means your .htaccess rules will be very much useless for that. To resume. You cannot use SEO url's or customer filenames/links with WHMCS anymore, starting with version 7 as they removed code from templates and put them behind routing classes. You will find out that most internal functions will default to the error page once they cannot find the file. My advise is not to use the SEO settings at all because its completely broken. I realize that the WHMCS SEF system is designed solely to function with the knowledgebase, so it appears that the routing class has fixed keywords, certainly not proper coding method, but it is what it is. I have devised a method which works, but is not ideal. If I can get it perfect, I'll post the process. 0 Quote Link to comment Share on other sites More sharing options...
yggdrasil Posted April 28, 2019 Share Posted April 28, 2019 3 hours ago, NadalKumar said: I realize that the WHMCS SEF system is designed solely to function with the knowledgebase, so it appears that the routing class has fixed keywords, certainly not proper coding method, but it is what it is. I have devised a method which works, but is not ideal. If I can get it perfect, I'll post the process. The method that works is combine: .htaccess Change the templates for the knowledgebase, and other files and replace the code with the pre 7 version links and SEO url structure Include Hooks that change the links again on the menus and articles PHP code on the error pages that detected the page directed 404 and redirect properly back the user to the proper page That is what I done and it's a complete mess. I mean mess because it requires many tricks and hacks to get something extremely simple done, which is using valid links and filenames. This was baby easy before version 7. And in my case its still buggy, some things don't work, like when someone changes the language while viewing a knowledgebase article it will default to an internal 404 so I had to disable that and just redirect to the main page. Again, this was working fine prior 7. Every single knowledgebase article in my setup had its own localized URL. It was beautiful, elegant and worked. I had my WHMCS site working the way I wanted and was very happy, then v7 came... Google traffic vanished on my site after v7 and that included my new sign up and sales because of broken front face. This was one of the biggest damage caused to my installation by a WHMCS upgrade, a year later I still don't have the time or energy to fix it because since I cannot access the encoded files I would be forced to create a completely new interface on top of WHMCS to get it to work my way just tapping directly into the database and leaving WHMCS out of the way. I considered not using WHMCS for news, help articles and other public facing stuff already because of the issues and just used it as a fancy billing system. The problem is that knowledgebase articles are integrated into tickets suggestions and canned replies, so it would mean the ticket system is also less useful since its not integrated with the rest of the knowledge base database. If you ever find a proper solution please post it. 0 Quote Link to comment Share on other sites More sharing options...
NadalKumar Posted April 29, 2019 Author Share Posted April 29, 2019 I was able to achieve the goal by placing a condition in the error/page-not-found.tpl so the html doe not display unless there is an actual condition of 404. Now the SEF router works perfectly with the extension. What was index.php?component=posts&view=post&category=1-uncategorized&post=12-end-user-license-agreement&menuid=9 Now display with SEF. See http://websitedons.net/demo/whmcs/whmcs-license and the blog posts now all have proper SEF urls http://websitedons.net/demo/whmcs/blogs An optional setting is included within the extensions configuration to make the SEF global to display cart urls as cart/hosting/great-package and with the robust menu system, the text cart can be any name assigned to the menu item or be removed entirely to read as site.com/hosting/ Login to the admin to test it all http://websitedons.net/demo/whmcs/admin/ usr: betatest pwd: betatest The edited error file {if $pagetitle|intval eq 404} <div class="container"> <div class="error-container boxed"> <h1><i class="fas fa-exclamation-triangle"></i> {lang key="errorPage.404.title"}</h1> <h3>{lang key="errorPage.404.subtitle"}</h3> <p>{lang key="errorPage.404.description"}</p> <div class="buttons"> <a href="{$systemurl}" class="btn btn-default"> {lang key="errorPage.404.home"} </a> <a href="{$systemurl}submitticket.php" class="btn btn-default"> {lang key="errorPage.404.submitTicket"} </a> </div> </div> </div> {/if} 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.