HostUp
WHMCS Friendly URLs Configuration option

WHMCS 7.8 Friendly URLs Configuration for Nginx

Switch Your VPS Hosting! Our SSD powered servers are both faster and cheaper than the competition, if not we'll match it!

Get Faster Hosting Today!

Hi there again! If you are like me and want to use the friendly URLs option with Nginx on WHMCS, but noticed that it does not work, then you have come to the right place.

Why Add SEO Friendly URLs?

Friendly URLs both look good for the user, is easier to remember and additionally help search engines, such as Google better understand your website.

An example of a regular URL
An example of an SEO friendly URL


Add the Configuration for WHMCS in Your Default.conf file.

This tutorial is very simple and you only need to edit one file,
default.conf. By default in nginx, this file is found in: /etc/nginx/conf.d/default.conf

You can edit this file by running the following command:

nano /etc/nginx/conf.d/default.conf 

Once you have opened your configuration file, proceed towards adding the following code to the file within the server paragraphs:

    # WHMCS CONFIG
    # When WHMCS updates, make sure to get the newest configuration at https://hostup.org/blog/whmcs-friendly-urls-configuration-for-nginx/

    location ~ /billing/announcements/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/announcements/$1;
    }

    location ~ /billing/download/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/download$1;
    }

    location ~ /billing/knowledgebase/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/knowledgebase/$1;
    }

    location ~ /billing/store/ssl-certificates/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/ssl-certificates/$1;
    }

    location ~ /billing/store/sitelock/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/sitelock/$1;
    }

    location ~ /billing/store/website-builder/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/website-builder/$1;
    }

    location ~ /billing/store/order/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/store/order/$1;
    }

    location ~ /billing/cart/domain/renew/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/cart/domain/renew$1;
    }

    location ~ /billing/account/paymentmethods/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/account/paymentmethods$1;
    }

    location ~ /billing/password/reset/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/password/reset/$1;
    }

    location ~ /billing/account/security/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/account/security$1;
    }

    location ~ /billing/subscription?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/subscription$1;
    }

#Social media authorization
    location ~ /billing/auth/provider/google_signin/finalize/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=auth/provider/google_signin/finalize$1;
    }

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

    location ~ /billing/admin/client/?(.*)/paymethods/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/paymethods/$1;
    }

    location ~ /billing/admin/setup/auth/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/setup/auth/$1;
    }

    location ~ /billing/admin/client/?(.*)/tickets/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/tickets/$1;
    }

    location ~ /billing/admin/client/?(.*)/invoice/?(.*)/capture/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/client/?(.*)/invoice/?(.*)/capture/$1;
    }

    location ~ /billing/admin/account/security/two-factor/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/admin/account/security/two-factor/$1;
    }

    location ~ /billing/admin/search/intellisearch?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/search/intellisearch/$1;
    }

# Security Advisory 2020-01-28
    location ^~ /vendor/ {
        deny all;
        return 403;
    }
# END WHMCS CONFIG

Save & exit by pressing CTRL + X followed by Y

Directory other than /billing

Alternatively, if you are using another directory, then this code will not work. You will have to replace ‘/billing/’ with your directory.

Here comes an example of this. Let’s say that we have our whmcs installed at another directory. For example, example.com/account. You then need to replace all of the bits of code in a similar mattar

location ~ /account/announcements/?(.*)$ {
    rewrite ^/(.*)$ /account/index.php?rp=/announcements/$1;
}

If you are instead using a subdomain, billing.example.com you can simply remove the /billing/ as shown below

location ~ /announcements/?(.*)$ {
    rewrite ^/(.*)$ /index.php?rp=/announcements/$1;
}

Directory other than /admin

If you have customized your admin directory – a security change that makes it harder for bots and other malicious users to find your login directory, then you need to make some changes to the above code.

You need to replace /admin/ with your /customdirectory/. You should follow this principle for all /admin/ as shown below.

location ~ /billing/customdirectory/setup/auth/?(.*)$ {
    rewrite ^/(.*)$ /billing/customdirectory/index.php?rp=/setup/auth/$1;
}
0 0 vote
Article Rating

David Berndtsson

Retired member at HostUp and loves to write tutorials that actually work.

Need VPS Hosting? Give HostUp a go! Our SSD powered servers will give you a blazing fast experience. From $3.50 / month.

View Plans

Subscribe
Notify of
guest
16 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Tab
1 year ago

One thing this doesn’t work for is the log-in integrations FB, Google, Twitter. These are still broken.

cam marry
cam marry
1 year ago

Hi,

i got a few problems with nginx rules for 7.8

https://**.com/admin/client/12345/tickets
https://**.com/admin/services/shared
https://**.com/admin/services/server
I just get an:

404 Not Found nginx

Any idea, how to fix it?

Martijn Kools
Martijn Kools
1 year ago

Hello I’m getting errors when searching for a client.

/billing/admin/search/client” failed (2: No such file or directory), client: 185.107.xx.xx, server: xxxx.com, request: “GET /billing/admin/search/client HTTP/1.1”, host: “xxxx.com”

Switching back to basic URLs fixes the issue.

JustAnotherUser
JustAnotherUser
11 months ago

Hi,

we had to add

location ~ /client/domain/(.*)/renew/?(.*)$ {
rewrite ^/(.*)$ /client/cart/domain/renew;
}

because the renew button on the domain management page (not the overview page) gave a 404. I don’t really know why the code above works, but it works.

Jonh
Jonh
10 months ago

Did you guys tried with this configuration block the access to “admin”?

Jonh
Jonh
10 months ago

Allow DataTables to read Sub/Accounts contacts and populate.

location ~ /clientes/auth/manage/client/links?(.*)$ {
rewrite ^/(.*)$ /clientes/index.php?rp=/contacts$1;
}

JustAnotherUser
JustAnotherUser
8 months ago
Reply to  Jonh

Didn’t work for me because the link in the original link had &cid=999 in the link and the rewritten link had ?cid=999 so I had to change it to:

location ~ /client/auth/manage/client/links?(.*)$ {
rewrite ^/(.*)$ /client/index.php?rp=/auth/manage/client/links&$1;
}

Where 999 is the example client ID.

Martijn Kools
Martijn Kools
10 months ago

Hi David any updates for 7.9? Thanks!

JustAnotherUser
JustAnotherUser
9 months ago

Hello everyone!
WHMCS Update 7.9 seems to break the payment link. I had to add the following:

location ~ /client/invoice/?(.*)$ {
rewrite ^/(.*)$ /client/index.php?rp=/invoice/$1/pay;
}

Just replace /client/ with your client area link.

Abdelkarim Mateos Sanchez

Hi.
For me not work.
Scenario:
Nginx 1.17.9 + PHP-FMP 7.2.24
Installed in owned subdomain intranet.domain.tld
Admin in /myadminxxxx/
All work fine (almost all checked) but domain renew in client interface fail
`
2020/03/09 11:31:56 [error] 26539#26539: *1 open() “/home/admin/web/iintranet.domain.tld/public_html/domain/domain.com/renew” failed (2: No such file or directory), client: 83.47.239.125, server: intranet.domain.tld, request: “GET /domain/domain.com/renew HTTP/1.1”, host: “intranet.domain.tld”, referrer: “https://intranet.domain.tld/clientarea.php?action=domaindetails&id=2758”

Of course adapted path for owned subdomain and for dir of admin.

Apreciate some help.

Martijn Kools
Martijn Kools
6 months ago

Is this still current with the latest WHMCS? I’m a bit scared to update. Thinking of switching to Apache anyway, it seems too much work to keep updated with this.

Copy link