Hướng dẫn các fix htaccess cho WHMCS trên Nginx

WHMCS Giza Data Tháng tám 7, 2023

Ở trường hợp này chúng ta sử dụng Ubuntu Server 20 và dùng Hostvn Script để sử dụng VPS dễ dàng hơn.

Điều cần làm sau khi tạo website ở menu Hostvn Script là edit file whmcs.conf nằm ở đường dẫn

/etc/nginx/rewrite

cách fix như sau. Edit file /etc/nginx/rewrite/whmcs.conf thành nội dung như sau

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

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

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

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

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

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

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

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

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

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

location / {
    # Redirect directories to an address with slash
    if (!-d $request_filename){
        rewrite ^/(.+)/$ /$1 permanent;
    }
    # Send all remaining (routable paths) through index.php
    if (!-e $request_filename){
        rewrite ^/(.*)$ /index.php last;
    }
}

Sau đó reboot lại vps là có thể sử dụng friendly urls của WHMCS rồi.

Quảng Cáo