Apache静态网站权限配置

<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} =off
RewriteRule ^ https://%{SERVER_NAME}:2053%{REQUEST_URI} [L]
</VirtualHost>

<VirtualHost *:443>
    DocumentRoot /var/www/html
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    SSLEngine on
    SSLCertificateFile "/root/ssl/joxqyd.feieryun.cn_bundle.crt"
    SSLCertificateKeyFile "/root/ssl/joxqyd.feieryun.cn.key"
    Protocols h2
    Alias "/users" "/users"
    <Directory />
        DirectoryIndex index.php
        AllowOverride FileInfo
        <Files ~ ".+">
            Deny from all
            Require all denied
        </Files>
        <Files ~ ".php$">
            Allow from all
        </Files>
        <Files ~ ".(html|htm|css|js|ttf|woff|ico|gif)">
            Allow from all
        </Files>
    </Directory>
    <Directory "/users">
        AllowOverride AuthConfig Indexes FileInfo
        php_admin_flag engine off
        Options Indexes
        IndexOptions FancyIndexing HTMLTable
        IndexOptions IgnoreCase
        IndexStyleSheet "/users/xixi/public/css/index.css"
        AuthType Basic
        AuthName "Restricted Area"
        AuthUserFile "/users/.htpasswd"
        <Files ~ ".+">
            Deny from all
            Require all denied
        </Files>
        <Files ~ "index\.html$">
            Allow from all
        </Files>
        <Files ~ ".(html|htm|css|js|ttf|woff|ico)">
            Allow from all
        </Files>
        <Files ~ ".(zip|rar|7z|mp3|jpg|png)$">
            Allow from all
        </Files>
    </Directory>

</VirtualHost>

/users/xixi/public/css/index.css

/* custom-style.css */
table {
    border-collapse: collapse;
    width: 100%;
    border: 1px solid #ddd; /* 添加细边框 */
}
th, td {
    border: 1px solid #ddd; /* 添加细边框 */
    padding: 8px;
    text-align: center;
}
.indexbreakrow {
    display: none;
}
.indexcolname {
    text-align: left;
}

必须在需要共享的文件夹中放上
.htaccess

DirectoryIndex
Require all granted
IndexIgnore *.htm *.html *.css
<Files ~ ".(html|htm|css|zip|rar|7z|mp3|jpg|png)$">
    Require all granted
</Files>
IndexIgnore "css"
AddDescription "纸飞机聊天软件" "tportable*"
AddDescription "WindowsFQ软件" "sing-box*"
AddDescription "ZIP压缩包" "*.zip"
AddDescription "7Z压缩包" "*.7z"
AddDescription "图片文件" "*.png"
AddDescription "MP3音乐" "mp3"
AddDescription "软件包" "software"
posted on 2023-12-28 10:58  项希盛  阅读(41)  评论(0)    收藏  举报