Search code examples
.htaccesswhmcs

WHMCS URL-friendly Custom created page with htaccess


I need to load WHMCS custom page without .php extension but it returns 404. URL friendly rules are set on htaccess as default. but they only apply for basic pages. the last solution would be to set custom rules on htaccess for specific URLs to load without the .php extension.


Solution

  • ended up setting custom rules on htaccess for each custom page to also load without the .php extension.

    <IfModule mod_rewrite.c>
    RewriteEngine on
    
    RewriteBase /
    
    #rempove .php for custom pages on by one
    RewriteRule ^customPageOne$ customPageOne.php [L]
    RewriteRule ^customPageTwo$ customPageTwo.php [L]
    RewriteRule ^customPageThree$ customPageThree.php [L]
    
    # Redirect directories to an address with slash
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+[^/])$  $1/ [R]
    
    # Send all remaining (routable paths) through index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # Determine and use the actual base
    RewriteCond $0#%{REQUEST_URI} ([^#]*)#(.*)\1$
    RewriteRule ^.*$ %2index.php [QSA,L]
    
    </IfModule>