Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion

Full friendly URLs configuration for WHMCS on NGINX
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Full friendly URLs configuration for WHMCS on NGINX

HostUpHostUp Member, Host Rep

Hey all :)

I posted a reply to this thread a while ago after creating URL rewrites for whmcs, but I think that this deserves its own thread for people looking for it.

This is required as NGINX does not support the .httaccess.

Nevertheless here is the tutorial
https://hostup.org/blog/whmcs-friendly-urls-configuration-for-nginx/
If you have any questions, or if I have missed something in this simple, yet non existant elsewhere let me know on here or on the article itself :)

Also this is tested for latest WHMCS 7.7

Comments

  • FalzoFalzo Member
    edited August 2019

    don't want to step on your toes, but I don't think simply creating a location per rewrite rule is a good way to say at least

    on top, you do have quite some blocks doubled up, which you easily can spot, if you sort them a bit better:

    /billing/announcements/?(.*)$
    /billing/cart/domain/renew/?(.*)$
    /billing/download/?(.*)$
    /billing/download/?(.*)$                     !!
    /billing/downloads/?(.*)$
    /billing/knowledgebase/?(.*)$
    /billing/knowledgebase/?(.*)$                !!
    /billing/store/order/?(.*)$
    /billing/store/order/?(.*)$                  !!
    /billing/store/sitelock/?(.*)$
    /billing/store/sitelock/?(.*)$               !!
    /billing/store/ssl-certificates/?(.*)$
    /billing/store/ssl-certificates/?(.*)$       !!
    /billing/store/website-builder/?(.*)$
    /billing/store/website-builder/?(.*)$        !!
    

    for the admin stuff you have redundant blocks which you don't need if you already rewrite the path above anyway

    /billing/admin/addons/?(.*)$
    /billing/admin/apps/?(.*)$
    /billing/admin/domains/?(.*)$
    /billing/admin/help/license/?(.*)$
    /billing/admin/setup/?(.*)$
    /billing/admin/setup/authn/view/?(.*)$                !!
    /billing/admin/setup/notifications/overview/?(.*)$    !!
    /billing/admin/setup/storage/index/?(.*)$             !!
    /billing/admin/setup/payments/tax/?(.*)$              !!
    /billing/admin/services/?(.*)$
    /billing/admin/services/shared/?(.*)$                 !!
    /billing/admin/services/reseller/?(.*)$               !!
    /billing/admin/services/server/?(.*)$                 !!
    /billing/admin/services/other/?(.*)$                  !!
    /billing/admin/utilities/system/php-compat/?(.*)$
    

    with that in mind, your stuff would already shorten by half ;-)

    besides that, you could have a look into the use of basic regular expressions to create something like

    location ~ /billing/admin/(addons|apps|domains|help\/license|services|setup|utilities\/system\/php-compat)(.*) {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/admin/$1$2 last; }
    

    just a suggestion, you'll get the idea and could easily bring it down to two rules overall maybe?
    I don't use WHMCS so obviously haven't tested it properly, go ahead and play around ;-)

    PS: totally forgot, you also might want to look into adding proper flags to the rewrite rule like last ;-)

  • HostUpHostUp Member, Host Rep
    edited August 2019

    @Falzo said:
    don't want to step on your toes, but I don't think simply creating a location per rewrite rule is a good way to say at least

    Yeah I totally agree, it might not be as compact but it works just as good. I am looking to make it more compact though (and I probably will tomorrow):p. I was new to nginx when I wrote this.

    I took most of your recommendations and implemented them :). The last compact one with the admin panel works great. Nevertheless I removed duplicates and sorted the code a bit more. Thanks for your awesome comment mate, and for helping me understand as well! :)

    Thanked by 1Falzo
  • HostUpHostUp Member, Host Rep
    edited May 2020

    It's come to my attention that I have gotten many requests for an updated version via mail and comments. I was wondering if anyone here already has one or would like to contribute to the existing blog post (I'll give you credit + backlink) to help others. I am no longer using NGINX but Litespeed instead so I am not really keeping track of all the changes anymore hence the outdated friendly URL rules.

    Thanks!

Sign In or Register to comment.