[英]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.有谁知道如何专门编写一个 .htaccess 文件来从 WHMCS 客户区中删除 .php,例如 clientarea.php 到 clientarea。 Also this will be needed to remove the .html extension from the knowledgebase articles as well.
此外,还需要从知识库文章中删除 .html 扩展名。
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. HTML 也是一样,将 .php 更改为 .html 使其看起来像这样。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)/$ $1.html
To have them both, the .htaccess should look like this:要同时拥有它们,.htaccess 应如下所示:
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 !确保启用
mod_rewrite
! If you do not have mod_rewrite
enabled, this won't work.如果您没有启用
mod_rewrite
,这将不起作用。
Mod_Rewrite is compiled with Apache by default on cPanel. Mod_Rewrite 在 cPanel 上默认使用 Apache 编译。
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:您可以通过
.htaccess
文件在 cPanel 中为帐户启用它,例如:
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.如果您没有 cPanel,我假设该命令是相同的,但请检查这是否对您不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.