【问题标题】:LiteSpeed .htaccess Remove File ExtensionLiteSpeed .htaccess 删除文件扩展名
【发布时间】:2019-01-03 08:55:55
【问题描述】:

我正在使用 LiteSpeed 7。我有一个用于删除文件扩展名的 .htaccess 文件,但 LiteSpeed 不支持。

我的 .htaccess 是这样的:

<IfModule mod_rewrite.c>
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME}.php -f 
    RewriteRule ^(.*)$ $1.php 
    RewriteRule ^([a-z]+)\/?$ $1.php [NC]  
 </IfModule>

我的项目文件需要 .html 和 .php 文件。

我该怎么做?

【问题讨论】:

    标签: .htaccess litespeed


    【解决方案1】:

    LiteSpeed Web Server 是当前版本 5.2.x 和 5.3RC2,似乎还不是 7。

    尝试了您的规则,似乎还可以。访问www.example.com/phpinfo,成功重定向到www.example.com/phpinfo.php

    也许您在当前规则之后还有其他规则?

    【讨论】:

      【解决方案2】:

      我发现这个 Block 必须被移除:

      # Access block for files
      # Apache < 2.3
      <IfModule !mod_authz_core.c>
          <FilesMatch "(?i:^\.|^#.*#|^(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|^composer\.(?:json|lock)|^ext_conf_template\.txt|^ext_typoscript_constants\.txt|^ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sqlite(?:\..*)?|sw[op]|git.*)|.*(?:~|rc))$">
              Order allow,deny
              Deny from all
              Satisfy All
          </FilesMatch>
      </IfModule>
      # Apache ≥ 2.3
      <IfModule mod_authz_core.c>
          <If "%{REQUEST_URI} =~ m#(?i:/\.|/\x23.*\x23|/(?:ChangeLog|ToDo|Readme|License)(?:\.md|\.txt)?|/composer\.(?:json|lock)|/ext_conf_template\.txt|/ext_typoscript_constants\.txt|/ext_typoscript_setup\.txt|flexform[^.]*\.xml|locallang[^.]*\.(?:xml|xlf)|\.(?:bak|co?nf|cfg|ya?ml|ts|typoscript|tsconfig|dist|fla|in[ci]|log|sh|sql(?:\..*)?|sqlite(?:\..*)?|sw[op]|git.*)|.*(?:~|rc))$#">
              Require all denied
          </If>
      </IfModule>
      

      但是如何替换呢?

      【讨论】:

        猜你喜欢
        • 2016-12-28
        • 2017-06-07
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-05-14
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多