How to Remove File Extension (.php) from URL using .htaccess in WHMCS? | WHMCS Global Services

How to Remove File Extension (.php) from URL using .htaccess in WHMCS?

Hi,

Have you ever thought you can remove .php extension in your whcms URL? Yes, you can. WGS providing the solution for removing the file extension in whmcs url.


BUY BEST WHMCS THEMES


Suppose if you want the URL ‘domain.com/whmcs/login.php‘ to display as ‘domain.com/whmcs/login‘ for whatever reason. Some like the way it looks, others believe it helps with SEO, and others believe it is better for security. I am unsure the last two hold any bit of truth, however. This is a feature you can implement via your htaccess file. This article will guide you through doing so via your cPanel.

  1. Log into your cPanel
  2. Find the Files category and click on the File Manager icon.
    step1
  3. A popup box will appear. For the primary domain, click on the Web Root radio button. For addon domains, click on the dropdown and find your desired addon domain name. Be sure the checkbox next to Show Hidden Files is checked. Click the Go button to enter the File Manager.
    step2
  4. You should now be in the root folder of the domain you chose. Look for the .htaccess file and right click on it. This brings up a menu. Find and click on the Edit option. If you get a popup box, simply find and click the Edit button in the lower right corner to continue to the editor.
    step3
  5. You are now in the text editor. As most sites are coded with either htm or php, we have include the code for both below.
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://your_domain.com/$1 [L,R=301]
    RewriteEngine On
    Options +FollowSymLinks
    Options -Indexes
    Options -MultiViews#RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]# Announcements
    RewriteRule ^announcements/([0-9]+)/[a-z0-9_-]+\.html$ ./announcements.php?id=$1 [L,NC]
    RewriteRule ^announcements$ ./announcements.php [L,NC]# Downloads
    RewriteRule ^downloads/([0-9]+)/([^/]*)$ ./downloads.php?action=displaycat&catid=$1 [L,NC]
    RewriteRule ^downloads$ ./downloads.php [L,NC]# Knowledgebase
    RewriteRule ^knowledgebase/([0-9]+)/[a-z0-9_-]+\.html$ ./knowledgebase.php?action=displayarticle&id=$1 [L,NC]
    RewriteRule ^knowledgebase/([0-9]+)/([^/]*)$ ./knowledgebase.php?action=displaycat&catid=$1 [L,NC]
    RewriteRule ^knowledgebase$ ./knowledgebase.php [L,NC]RewriteCond %{REQUEST_FILENAME}.php -f
    RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
  6. Be sure to hit the Save Changes button in the upper right corner to save your new htaccess configuration. Your site should now display the address without the file extension.
Looking for Something More? We can help!

Our WHMCS experts are ready to accept your custom requirements.