htaccess阻止直接访问具有异常的特定文件扩展名

时间:2015-05-09 09:43:21

标签: .htaccess

我试图阻止用户直接访问任何文件或目录,除了我的index.php使用这个htaccess:

deny from all

我刚在php include文件夹中使用了另一个htaccess:

<link rel="shortcut icon" href="img/favicon.png" type="image/x-icon" />  

一切正常,除非它阻止我的图标显示。我的index.php中的代码:

$(document).on('click', ".item-select", function(e) {

        e.preventDefault;

        var product = $(this);

        $('#insert').modal({ backdrop: 'static', keyboard: false }).one('click', '#selected', function(e) {

            var itemText = $('#insert').find("option:selected").text();
            var itemValue = $('#insert').find("option:selected").val();

            $(product).closest('tr').find('#invoice_product').val(itemText);
            $(product).closest('tr').find('#invoice_product_price').val(itemValue);

            //updateTotals('#invoice_table');
            //calculateTotal();

        });

        return false;

    });

// add new product row on invoice
    var cloned = $('#invoice_table tr:last').clone();
    $(".add-row").click(function(e) {
        e.preventDefault();
        cloned.clone().appendTo('#invoice_table'); 
    });

    calculateTotal();

    $('#invoice_table').on('change keyup paste touchend', '.calculate', function() {
        updateTotals(this);
        calculateTotal();
    });

    $('#invoice_totals').on('change keyup paste touchend', '.calculate', function() {
        calculateTotal();
    });

    function updateTotals(elem) {

        var tr = $(elem).closest('tr'),
            quantity = $('[name="invoice_product_qty[]"]', tr).val(),
            price = $('[name="invoice_product_price[]"]', tr).val(),
            isPercent = $('[name="invoice_product_discount[]"]', tr).val().indexOf('%') > -1,
            percent = $.trim($('[name="invoice_product_discount[]"]', tr).val().replace('%', '')),
            subtotal = parseInt(quantity) * parseFloat(price);

        if(percent && $.isNumeric(percent) && percent !== 0) {
            if(isPercent){
                subtotal = subtotal - ((parseFloat(percent) / 100) * subtotal);
            } else {
                subtotal = subtotal - parseFloat(percent);
            }
        } else {
            $('[name="invoice_product_discount[]"]', tr).val('');
        }

        $('.calculate-sub', tr).val(subtotal.toFixed(2));
    }

    function calculateTotal() {

        var grandTotal = 0,
            disc = 0,
            c_ship = parseInt($('.calculate.shipping').val()) || 0;

        $('#invoice_table tbody tr').each(function() {
            var c_sbt = $('.calculate-sub', this).val(),
                quantity = $('[name="invoice_product_qty[]"]', this).val(),
                price = $('[name="invoice_product_price[]"]', this).val() || 0,
                subtotal = parseInt(quantity) * parseFloat(price);

            grandTotal += parseFloat(c_sbt);
            disc += subtotal - parseFloat(c_sbt);
        });

        // VAT, DISCOUNT, SHIPPING, TOTAL, SUBTOTAL:
        var subT = parseFloat(grandTotal),
            finalTotal = parseFloat(grandTotal + c_ship),
            vat = parseInt($('.invoice-vat').attr('data-vat-rate'));

        $('.invoice-sub-total').text(subT.toFixed(2));
        $('#invoice_subtotal').val(subT.toFixed(2));
        $('.invoice-discount').text(disc.toFixed(2));
        $('#invoice_discount').val(disc.toFixed(2));

        if($('.invoice-vat').attr('data-enable-vat') === '1') {

            if($('.invoice-vat').attr('data-vat-method') === '1') {
                $('.invoice-vat').text(((vat / 100) * subT).toFixed(2));
                $('#invoice_vat').val(((vat / 100) * subT).toFixed(2));
                $('.invoice-total').text((finalTotal).toFixed(2));
                $('#invoice_total').val((finalTotal).toFixed(2));
            } else {
                $('.invoice-vat').text(((vat / 100) * subT).toFixed(2));
                $('#invoice_vat').val(((vat / 100) * subT).toFixed(2));
                $('.invoice-total').text((finalTotal + ((vat / 100) * finalTotal)).toFixed(2));
                $('#invoice_total').val((finalTotal + ((vat / 100) * finalTotal)).toFixed(2));
            }
        } else {
            $('.invoice-total').text((finalTotal).toFixed(2));
            $('#invoice_total').val((finalTotal).toFixed(2));
        }

    }

如何允许显示图标的访问权限?

1 个答案:

答案 0 :(得分:1)

RewriteEngine On行下方包含此规则以允许访问favicon

RewriteRule img/favicon\.png$ - [NC,L]
相关问题