HostUp
WHMCS Friendly URLs Configuration option

WHMCS 7.7 Friendly URLs Configuration for Nginx

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

 #WHMCS ADMIN

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

# 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;
}

David

Want Ubuntu tutorials that actually work? Then you have found the right person

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
DavidTab Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Tab
Guest

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

Most popular

Most discussed