【问题标题】:WHMCS .htaccess Remove .php and .htmlWHMCS .htaccess 移除 .php 和 .html
【发布时间】:2018-03-10 04:34:57
【问题描述】:

有谁知道如何专门编写一个.htaccess 文件来从WHMCS 客户区删除.php,例如clientarea.php 到clientarea。这也需要从知识库文章中删除 .html 扩展名。

我在下面尝试过,但它不起作用:

    #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]

提前感谢您的帮助!

【问题讨论】:

    标签: php html .htaccess


    【解决方案1】:

    这应该可行:

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

    HTML 也是一样,把 .php 改成 .html 就变成了这样。

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

    要同时拥有它们,.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
    

    确保启用mod_rewrite!如果您没有启用mod_rewrite,这将不起作用。

    【讨论】:

      【解决方案2】:

      Mod_Rewrite 默认在 cPanel 上使用 Apache 编译。

      代码:

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

      您可以通过 .htaccess 文件在 cPanel 中为帐户启用它,其中包含如下行:

      RewriteEngine on
      

      如果您没有 cPanel,我假设该命令将是相同的,但请检查它是否不适合您。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-08-11
        • 1970-01-01
        • 2014-03-04
        • 2011-06-01
        • 1970-01-01
        • 2017-06-11
        • 2013-05-17
        相关资源
        最近更新 更多