转义等于符号,加上mod_rewrite的符号和斜杠

时间:2016-08-31 04:31:11

标签: apache .htaccess mod-rewrite

我使用GET传递base64编码参数。转换为base64后,我最终得到一个包含斜杠的字符串,加上和等于破坏我的mod_rewrite规则的符号。我的mod_rewrite规则是

Public Sub exportToexcel()


    Dim default_location As String = "D:\Book1.xlsx"

    Dim dset As New DataSet

    dset.Tables.Add()

    For i As Integer = 0 To dgvReports.ColumnCount - 1
       dset.Tables(0).Columns.Add(dgvReports.Columns(i).HeaderText)
    Next
    add rows to the table
    Dim dr1 As DataRow
    For i As Integer = 0 To dgvReports.RowCount - 1
        dr1 = dset.Tables(0).NewRow
        For j As Integer = 0 To dgvReports.Columns.Count - 1

            dr1(j) = dgvReports.Rows(i).Cells(j).Value


        Next
        dset.Tables(0).Rows.Add(dr1)
    Next

    Dim excel As Microsoft.Office.Interop.Excel.Application
    excel = New Microsoft.Office.Interop.Excel.Application
    Dim wBook As Microsoft.Office.Interop.Excel.Workbook
    Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet

    excel.Visible = True
    excel.UserControl = True

    wBook = excel.Workbooks.Add(System.Reflection.Missing.Value)
    wSheet = wBook.Sheets("Sheet1")
    excel.Range("A50:I50").EntireColumn.AutoFit()
    With wBook
        .Sheets("Sheet1").Select()
        .Sheets(1).Name = "Sheet1"

    End With

    Dim dt As System.Data.DataTable = dset.Tables(0)
    ' wSheet.Cells(1).value = strFileName
    For Each col As DataGridViewColumn In dgvReports.Columns
        wSheet.Cells(1, col.Index + 1) = col.HeaderText.ToString
    Next


    For i = 0 To dgvReports.RowCount - 1
        For j = 0 To dgvReports.ColumnCount - 1
            wSheet.Columns.NumberFormat = "@"
            wSheet.Cells(i + 2, j + 1).value = dgvReports.Rows(i).Cells(j).Value.ToString
        Next j
    Next i

    wSheet.Columns.AutoFit()


    Dim blnFileOpen As Boolean = False
    Try
        Dim fileTemp As System.IO.FileStream = System.IO.File.OpenWrite(default_location)
        fileTemp.Close()
    Catch ex As Exception
        blnFileOpen = False
    End Try

    If System.IO.File.Exists(default_location) Then
        System.IO.File.Delete(default_location)
    End If
    wBook.SaveAs(default_location)
    excel.Workbooks.Open(default_location)
    excel.Visible = True
End Sub

代码参数是base64。有没有办法自动逃避这些角色?

1 个答案:

答案 0 :(得分:1)

尝试使用[B]标志,但我不确定

RewriteRule ^page/(\w+)$  page.php?code=$1 [B]
  

[B]标志指示RewriteRule转义非字母数字   应用转换前的字符。

http://httpd.apache.org/docs/2.2/rewrite/flags.html#flag_b