使用多个变量重定向格式错误的URL

时间:2015-12-16 05:28:30

标签: apache .htaccess variables redirect malformed

使用"格式错误的双重重定向?"

我尝试以下操作:必须保持活动的旧URL形成如下: /index.php?id=5041?var1=val1&var2=val2&var3=val3

我必须将它重定向到这样的东西:

/path1/path2/?id=1234?var1=val1&var2=val2&var3=val3

无论我尝试什么 - 它都是index.php中的无限循环,或者在id之后剪切其余的变量。字符串的其余部分应该简单地附上。

#Only if id = 1234
RewriteCond %{QUERY_STRING} ^id=1234? [NC]
#get id for variable $1
RewriteCond %{QUERY_STRING} id=(\d+) [NC]
#get rest for variable $2
RewriteCond %{QUERY_STRING} val1=(\d+) [NC]
RewriteRule ^index\.php$ /path1/path2/?myid=%1&val2=%2

1 个答案:

答案 0 :(得分:0)

Submission

上述条件

Sub Submission()

    Dim wksCS As Worksheet, wksSQR As Worksheet

    Set wksCS = Worksheets("Consolidated_Sheet")
    Set wksSQR = Worksheets("SQR_Report_Raw_Data")

    'look up colU against colJ - copy match from ColF to ColO
    DoLookup wksCS.Columns("U"), wksSQR.Columns("J"), "F", "O"

    'add more lookups here....


End Sub

'Utility: for each value in SrcCol, check MatchCol for a match.
'  If found, copy the value from Col 'ValCol' on the matched row to Col 'DestCol' on
'   the consolidation sheet.
Sub DoLookup(SrcCol As Range, MatchCol As Range, ValCol As String, DestCol As String)
    Dim rngSrc As Range, rngMatch As Range, c As Range, v, m
    'just work with the "used" parts of the match columns
    Set rngSrc = Application.Intersect(SrcCol, SrcCol.Parent.UsedRange)
    Set rngMatch = Application.Intersect(MatchCol, MatchCol.Parent.UsedRange)

    For Each c In rngSrc.Cells
        v = c.Value
        If Len(v) > 0 Then
            m = Application.Match(v, rngMatch, 0)
            If Not IsError(m) Then
                c.EntireRow.Cells(1, DestCol).Value = _
                   rngMatch.Cells(m).EntireRow.Cells(1, ValCol)
            Else
                'decide what you want to do here...
                c.EntireRow.Cells(1, DestCol).Value = "No match!"
            End If
        End If
    Next c
End Sub

检查/index.php是否具有特定的查询字符串,将其重定向到新位置。