回答編集履歴

1

補足に対して追記。

2023/02/28 10:59

投稿

otn
otn

スコア84533

test CHANGED
@@ -18,3 +18,16 @@
18
18
 
19
19
  `/aa1/~`も除外しておかないと、`https://example.com/`→`https://example.com/aa1/`→`https://example.com/aa1/aa1/`→`https://example.com/aa1/aa1/aa1/`とリダイレクトし続ける気がしますが、大丈夫だったのでしょうか?
20
20
 
21
+ ## 追記
22
+ > いえ、ピンポイントで https://hogehoge.com/ http://hogehoge.com/ だけを https://hogehoge.com/aa1/ に飛ばしてほしいのです。
23
+ ということなので。
24
+ その場合は、簡単です。パスの`/`以降が空の時だけリダイレクトすれば良いので、
25
+ ```Apache
26
+ RewriteEngine On
27
+ RewriteCond %{HTTP_HOST} ^example\.com$
28
+ RewriteRule ^$ /aa1/ [R=302,L]
29
+
30
+ RewriteCond %{HTTPS} off
31
+ RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
32
+ ```
33
+