0

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!

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.