RewriteRule仅适用于主页

时间:2019-04-26 14:18:42

标签: .htaccess mod-rewrite s3-rewrite-rules

我有这个RewriteRule,它创建了从example1.com到example2.com的永久重定向

在example1.com的htaccess中,我有以下规则:

Public Sub CreateArray()

    Dim myArrayOfMonths(11) As Double

    Dim currentWorkbook As Workbook
    Dim currentSheet As Worksheet
    Dim otherSheet As Worksheet

    Dim r As Integer
    Dim c As Integer

    Set currentWorkbook = ActiveWorkbook
    Set otherSheet = currentWorkbook.Worksheets("Output")

    For Each currentSheet In currentWorkbook.Worksheets

        r = 20

        For c = 4 To 15
            myArrayOfMonths(c - 4) = myArrayOfMonths(c - 4) + currentSheet.Cells(r, c)
        Next c

    Next currentSheet

    otherSheet.Range("B1:M1").Value = myArrayOfMonths

    Set currentSheet = Nothing
    Set currentWorkbook = Nothing

End Sub

重定向对于https://www.example1.com/正常工作(它被重定向到https://www.example2.com)。但这不适用于https://www.example1.com/about-us

我希望将https://www.example1.com/about-us重定向到https://www.example2.com/about-us

1 个答案:

答案 0 :(得分:0)

将您的重写更改为此:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example1\.com [NC]
RewriteRule (.*) https://www.example2.com/$1 [R=301,L]