Howdy, Stranger!

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

Advertise on LowEndTalk.com

In this Discussion

Full friendly URLs configuration for WHMCS on NGINX
New on LowEndTalk? Please read our 'Community Rules' by clicking on it in the right menu!

Full friendly URLs configuration for WHMCS on NGINX

HostUpHostUp Member, Provider

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

David B. from HostUp, LLC | Web & VPS Hosting in Netherlands | DDoS protection | $3,50/mo
Also writes awesome tutorials for ubuntu on blog

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 ;-)

    most recommended Provider: First-Root KVM Power-Edition /w SSD
    UltraVPS.eu KVM in US/UK/NL/DE: 15% off first 6 month | Netcup VPS/rootDS - 5€ off: 36nc15279180197 (ref)

  • HostUpHostUp Member, Provider
    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

    David B. from HostUp, LLC | Web & VPS Hosting in Netherlands | DDoS protection | $3,50/mo
    Also writes awesome tutorials for ubuntu on blog

  • HostUpHostUp Member, Provider
    edited May 16

    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!

    David B. from HostUp, LLC | Web & VPS Hosting in Netherlands | DDoS protection | $3,50/mo
    Also writes awesome tutorials for ubuntu on blog

Sign In or Register to comment.