回答編集履歴

2

そうか。クエリを消さないとループしますね。

2018/07/12 05:55

投稿

rogueref
rogueref

スコア727

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  RewriteCond %{HTTPS} on
10
10
 
11
- RewriteRule .* https://www.example.com/bbb/ccc.html [R,L]
11
+ RewriteRule .* https://www.example.com/bbb/ccc.html? [R,L]
12
12
 
13
13
 
14
14
 
@@ -26,6 +26,8 @@
26
26
 
27
27
  クエリ文字列とリダイレクト先URIが一致しているのならバックリファレンスを使えます。
28
28
 
29
+ あと、クエリを消さないとリダイレクトがループします。
30
+
29
31
  https://www.example.com/?xxx=123 を
30
32
 
31
33
  https://www.example.com/bbb/123.html へリダイレクトするなら以下のような感じ。
@@ -38,7 +40,7 @@
38
40
 
39
41
  RewriteCond %{HTTPS} on
40
42
 
41
- RewriteRule .* https://www.example.com/bbb/%1.html [R,L]
43
+ RewriteRule .* https://www.example.com/bbb/%1.html? [R,L]
42
44
 
43
45
  ```
44
46
 

1

コメントから追加要求仕様。

2018/07/12 05:55

投稿

rogueref
rogueref

スコア727

test CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  RewriteCond %{HTTPS} on
10
10
 
11
- RewriteRule .* https://www.aaa.com/bbb/ccc.html
11
+ RewriteRule .* https://www.example.com/bbb/ccc.html [R,L]
12
12
 
13
13
 
14
14
 
@@ -17,3 +17,31 @@
17
17
 
18
18
 
19
19
  うまく行かなかった場合は、試したことも質問内容にかくといいでしょう。
20
+
21
+
22
+
23
+ (追記)
24
+
25
+ クエリ文字列によってリダイレクト先を変えたいとのこと。
26
+
27
+ クエリ文字列とリダイレクト先URIが一致しているのならバックリファレンスを使えます。
28
+
29
+ https://www.example.com/?xxx=123 を
30
+
31
+ https://www.example.com/bbb/123.html へリダイレクトするなら以下のような感じ。
32
+
33
+
34
+
35
+ ```
36
+
37
+ RewriteCond %{QUERY_STRING} xxx=(\d+)
38
+
39
+ RewriteCond %{HTTPS} on
40
+
41
+ RewriteRule .* https://www.example.com/bbb/%1.html [R,L]
42
+
43
+ ```
44
+
45
+
46
+
47
+ クエリ文字列とリダイレクト先URIになんの関係もないのなら、一つづつ書くしかありません。