简体   繁体   中英

WHMCS .htaccess Remove .php and .html

Does anyone know how to specifically write an .htaccess file to remove .php from WHMCS client area, for example clientarea.php to clientarea. Also this will be needed to remove the .html extension from the knowledgebase articles as well.

I have tried this below but it is not working:

    #Force non-.php:
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^([^\.]+)$ $1.php [NC,L]

Thank you for any help in advance!

This should work:

  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^([^\.]+)/$ $1.php 

HTML is the same story, change .php to .html so it would look like this.

  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.html -f
  RewriteRule ^([^\.]+)/$ $1.html

To have them both, the .htaccess should look like this:

  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.php -f
  RewriteRule ^([^\.]+)/$ $1.php 

  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME}\.html -f
  RewriteRule ^([^\.]+)/$ $1.html

Make sure to have mod_rewrite enabled ! If you do not have mod_rewrite enabled, this won't work.

Mod_Rewrite is compiled with Apache by default on cPanel.

Code:

root@server [~]# httpd -l|grep rewrite
  mod_rewrite.c

You can enable it in cPanel for an account through the .htaccess file with a line such as:

RewriteEngine on

If you don't have cPanel I'm assuming the command would be some what the same but check if that doesn't work for you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM