默认情况ECMS系统执行站点初始化会自动创建或更新重写文件,当用户手动更改或服务器权限问题导致重写文件异常,可以通过复制以下代码生成:
<Files ~ ".(tpl|cache|db|sql|log|cache)$">
<IfModule authz_core_module>
Require all denied
</IfModule>
<IfModule !authz_core_module>
Deny from all
</IfModule>
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
Options -Indexes
#DirectoryIndex index.html index.php
DirectoryIndex index.php
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [PT,L]
</IfModule>
模板目录一般不会公开访问,模板里的静态资源程序默认会通过PHP路由查找正确路径,但是经过PHP路由解析会消耗一定的资源,可以通过apache-htaccess重写功能定义模板静态资源路径,例如:
RewriteEngine On
Options -Indexes
DirectoryIndex index.php index.html
RewriteBase /
RewriteRule ^assets/(.+)$ esite_template/template_1/assets/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [PT,L]