HostUp

WHMCS 7.7 Friendly URLs Configuration for Nginx

WHMCS Friendly URLs Configuration option

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 paragraphs:

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

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

    location ~ /billing/downloads/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/downloads/$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/download/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/download$1;
    }

    location ~ /billing/cart/domain/renew/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/cart/domain/renew$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/download/?(.*)$ {
        rewrite ^/(.*)$ /billing/index.php?rp=/download$1;
    }

 #WHMCS ADMIN
    location ~ /billing/admin/setup/authn/view/?(.*)$ {
        rewrite ^/(.*)$ /billing/admin/index.php?rp=/admin/setup/authn/view/$1;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

# END WHMCS CONFIG

If you are using example.com/billing, then this code will work. If you are using something else, example.com/manage then replace ‘/billing/’ with your URL.

Add comment