teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2020/11/12 12:35

投稿

otn
otn

スコア86363

answer CHANGED
@@ -3,4 +3,17 @@
3
3
  RewriteCond /another/path/to/image1.jpg -f
4
4
  RewriteRule ^path/to/image1.jpg$ /another/path/to/image1.jpg [E]
5
5
  RewriteRule ^path/to/image1.jpg$ /image.php?gen=/path/to/image1.jpg [E]
6
- ```
6
+ ```
7
+ #追記
8
+ もしかして、固定URLじゃなくて、「ファイルが存在しないURLすべて」ということですかね?
9
+ ```Apahe
10
+ RewriteEngine On
11
+ RewriteCond %{REQUEST_FILENAME} !-f
12
+ RewriteCond %{REQUEST_FILENAME} !-d
13
+ RewriteCond %{DOCUMENT_ROOT}/another/$1 -f
14
+ RewriteRule ^(.*)$ /another/$1 [E]
15
+ RewriteCond %{REQUEST_FILENAME} !-f
16
+ RewriteCond %{REQUEST_FILENAME} !-d
17
+ RewriteRule ^(.*)$ /image.php?gen=/$1 [E]
18
+ ```
19
+ ドキュメントルート以外に書く場合はパス名の調整が必要です。

1

訂正

2020/11/12 12:35

投稿

otn
otn

スコア86363

answer CHANGED
@@ -1,6 +1,6 @@
1
1
  ```Apache
2
2
  RewriteEngine On
3
3
  RewriteCond /another/path/to/image1.jpg -f
4
- RewriteRule ^path/to/image1.jpg /another/path/to/image1.jpg [E]
4
+ RewriteRule ^path/to/image1.jpg$ /another/path/to/image1.jpg [E]
5
- RewriteRule ^path/to/image1.jpg /image.php?gen=/path/to/image1.jpg [E]
5
+ RewriteRule ^path/to/image1.jpg$ /image.php?gen=/path/to/image1.jpg [E]
6
6
  ```