回答編集履歴
5
文章の修正・結果を追加
answer
CHANGED
@@ -1,19 +1,21 @@
|
|
1
|
-
|
1
|
+
RewriteRule で、404 を返したいのであれば、フラグとして R=404 をつけます。
|
2
2
|
|
3
3
|
ヒントとしては...
|
4
|
+
http の場合だけ 404 にするには、下記の2行で、404 エラーを返せます。
|
4
5
|
```
|
5
6
|
RewriteCond %{HTTPS} off
|
6
7
|
RewriteRule ^aiueo.html$ - [R=404,L]
|
7
8
|
```
|
8
|
-
(.htaccess では、うまく動かなかったので修正しました。)
|
9
9
|
|
10
10
|
詳しくは、マニュアル [RewriteRule Flags](https://httpd.apache.org/docs/2.4/rewrite/flags.html) を参照。
|
11
11
|
|
12
12
|
----
|
13
13
|
|
14
|
-
(検証を追加)
|
14
|
+
(検証を追加)
|
15
|
-
|
15
|
+
http ステータスを確認するために wget コマンドで接続してテスト。
|
16
|
+
.htaccess で設定後に URL ( http://example.com/aiueo.html )を開くと 以下のように 404 レスポンスになってます。 https ( https://example.com/aiueo.html )でアクセスすると 200レスポンスで、ファイルを取得できています。
|
16
17
|
|
18
|
+
http の場合、404 ( = エラー )
|
17
19
|
```
|
18
20
|
$ wget http://example.com/aiueo.html
|
19
21
|
|
@@ -22,5 +24,15 @@
|
|
22
24
|
Connecting to example.com|192.168.1.10|:80... connected.
|
23
25
|
HTTP request sent, awaiting response... 404 Not Found
|
24
26
|
2018-01-10 13:07:57 ERROR 404: Not Found.
|
27
|
+
```
|
28
|
+
https の場合は、200 (= OK)
|
29
|
+
```
|
30
|
+
$ wget https://example.com/aiueo.html
|
25
31
|
|
32
|
+
--2018-01-10 13:57:38-- http://example.com/aiueo.html
|
33
|
+
Resolving example.com... 192.168.1.112, 192.168.1.10
|
34
|
+
Connecting to example.com|192.168.1.10|:443... connected.
|
35
|
+
HTTP request sent, awaiting response... 200 OK
|
36
|
+
Length: 50 [text/html]
|
37
|
+
Saving to: 'aiueo.html'
|
26
38
|
```
|
4
修正
answer
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
$ wget http://example.com/aiueo.html
|
19
19
|
|
20
20
|
--2018-01-10 13:07:57-- http://example.com/aiueo.html
|
21
|
-
Resolving
|
21
|
+
Resolving example.com... 192.168.1.112, 192.168.1.10
|
22
22
|
Connecting to example.com|192.168.1.10|:80... connected.
|
23
23
|
HTTP request sent, awaiting response... 404 Not Found
|
24
24
|
2018-01-10 13:07:57 ERROR 404: Not Found.
|
3
アクセス結果を追加
answer
CHANGED
@@ -7,4 +7,20 @@
|
|
7
7
|
```
|
8
8
|
(.htaccess では、うまく動かなかったので修正しました。)
|
9
9
|
|
10
|
-
詳しくは、マニュアル [RewriteRule Flags](https://httpd.apache.org/docs/2.4/rewrite/flags.html) を参照。
|
10
|
+
詳しくは、マニュアル [RewriteRule Flags](https://httpd.apache.org/docs/2.4/rewrite/flags.html) を参照。
|
11
|
+
|
12
|
+
----
|
13
|
+
|
14
|
+
(検証を追加)
|
15
|
+
.htaccess で設定した URL を開くと 以下のように 404 レスポンスになってます。
|
16
|
+
|
17
|
+
```
|
18
|
+
$ wget http://example.com/aiueo.html
|
19
|
+
|
20
|
+
--2018-01-10 13:07:57-- http://example.com/aiueo.html
|
21
|
+
Resolving dns.cherry.jp... 192.168.1.112, 192.168.1.10
|
22
|
+
Connecting to example.com|192.168.1.10|:80... connected.
|
23
|
+
HTTP request sent, awaiting response... 404 Not Found
|
24
|
+
2018-01-10 13:07:57 ERROR 404: Not Found.
|
25
|
+
|
26
|
+
```
|
2
.htaccess では、うまく動かなかったので修正
answer
CHANGED
@@ -1,1 +1,10 @@
|
|
1
|
+
存在する URL に対して、RewriteRule で、404 を返したいのであれば、フラグとして R=404 をつけます。
|
2
|
+
|
3
|
+
ヒントとしては...
|
4
|
+
```
|
5
|
+
RewriteCond %{HTTPS} off
|
6
|
+
RewriteRule ^aiueo.html$ - [R=404,L]
|
7
|
+
```
|
1
|
-
|
8
|
+
(.htaccess では、うまく動かなかったので修正しました。)
|
9
|
+
|
10
|
+
詳しくは、マニュアル [RewriteRule Flags](https://httpd.apache.org/docs/2.4/rewrite/flags.html) を参照。
|
1
間違っていたので、削除
answer
CHANGED
@@ -1,7 +1,1 @@
|
|
1
|
-
RewriteRule で、404 を返したいのであれば、フラグとして R=404 をつけます。
|
2
|
-
|
3
|
-
ヒントとしては...
|
4
|
-
```
|
5
|
-
|
1
|
+
ミスがあったので、再確認のため、削除。
|
6
|
-
RewriteRule /aiueo.html - [R=404,L]
|
7
|
-
```
|