十月CMS目录豁免

3

我正在尝试创建一个独立于OctoberCMS系统之外的单个目录。在.htaccess文件中,我添加了以下行:

RewriteCond %{REQUEST_URI} !public/.* [NC]

这个方法对于public/image.gif非常有效,但是public/file.html无法使用。它会跳转到一个404页面,不是Apache的404页面,而是OctoberCMS的页面。
我希望至少有一个目录完全脱离正常结构。我很烦恼这个CMS已经完全控制了整个域名,没有留下任何空间给不属于它的东西。
1个回答

2
我发现问题有两个方面。一方面,我必须输入上面的那一行来启用对公共文件夹的访问,但是我还必须将.html扩展名添加到白名单区域。我原以为第一个指令会覆盖对白名单的需求,但实际情况并非如此。如果需要更多自定义,我现在可以根据需要进行调整。
php_flag opcache.enable Off
<IfModule mod_rewrite.c>

    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    ##
    ## You may need to uncomment the following line for some hosting environments,
    ## if you have installed to a subdirectory, enter the name here also.
    ##
    # RewriteBase /

    ##
    ## Black list protected files
    ##

    RewriteRule ^themes/.*/(layouts|pages|partials)/.*.htm index.php [L,NC]
    RewriteRule ^bootstrap/.* index.php [L,NC]
    RewriteRule ^config/.* index.php [L,NC]
    RewriteRule ^vendor/.* index.php [L,NC]
    RewriteRule ^storage/cms/.* index.php [L,NC]
    RewriteRule ^storage/logs/.* index.php [L,NC]
    RewriteRule ^storage/framework/.* index.php [L,NC]
    RewriteRule ^storage/temp/protected/.* index.php [L,NC]
    RewriteRule ^storage/app/uploads/protected/.* index.php [L,NC]

    ##
    ## White listed folders and files
    ##
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteCond %{REQUEST_URI} !\.js$
    RewriteCond %{REQUEST_URI} !\.map$
    RewriteCond %{REQUEST_URI} !\.ico$
    RewriteCond %{REQUEST_URI} !\.jpg$
    RewriteCond %{REQUEST_URI} !\.jpeg$
    RewriteCond %{REQUEST_URI} !\.bmp$
    RewriteCond %{REQUEST_URI} !\.png$
    RewriteCond %{REQUEST_URI} !\.gif$
    RewriteCond %{REQUEST_URI} !\.svg$
    RewriteCond %{REQUEST_URI} !\.css$
    RewriteCond %{REQUEST_URI} !\.less$
    RewriteCond %{REQUEST_URI} !\.scss$
    RewriteCond %{REQUEST_URI} !\.pdf$
    RewriteCond %{REQUEST_URI} !\.swf$
    RewriteCond %{REQUEST_URI} !\.txt$
    RewriteCond %{REQUEST_URI} !\.xml$
    RewriteCond %{REQUEST_URI} !\.xls$
    RewriteCond %{REQUEST_URI} !\.eot$
    RewriteCond %{REQUEST_URI} !\.woff$
    RewriteCond %{REQUEST_URI} !\.woff2$
    RewriteCond %{REQUEST_URI} !\.ttf$
    RewriteCond %{REQUEST_URI} !\.flv$
    RewriteCond %{REQUEST_URI} !\.wmv$
    RewriteCond %{REQUEST_URI} !\.mp3$
    RewriteCond %{REQUEST_URI} !\.ogg$
    RewriteCond %{REQUEST_URI} !\.wav$
    RewriteCond %{REQUEST_URI} !\.avi$
    RewriteCond %{REQUEST_URI} !\.mov$
    RewriteCond %{REQUEST_URI} !\.mp4$
    RewriteCond %{REQUEST_URI} !\.mpeg$
    RewriteCond %{REQUEST_URI} !\.webm$
    RewriteCond %{REQUEST_URI} !\.mkv$
    RewriteCond %{REQUEST_URI} !\.rar$
    RewriteCond %{REQUEST_URI} !\.zip$
    ## Add This here
    RewriteCond %{REQUEST_URI} !\.html$
    RewriteCond %{REQUEST_URI} !docs/.*
    RewriteCond %{REQUEST_URI} !themes/.*
    RewriteRule ^ index.php [L,NC]

    ##
    ## Standard routes
    ##

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

</IfModule>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接