0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Apache 2.4 + Laravel】特定APIにアップロードファイルの上限指定する方法

Posted at

【Apache 2.4 + Laravel】特定APIにアップロードファイルの上限指定する方法

概要

特定のWebAPIのみ、アップロードするファイルサイズ上限を上げる手順を
備忘録として残します。

環境

・Apache 2.4
・Laravel

手順

LaravelプロジェクトのPublic配下にある.htaccessファイルにて
下記を追記します。

例)post/createに設定する場合
     <If "%{THE_REQUEST} =~ /.*post\x2Fcreate.*/">
         php_value post_max_size 500M
         php_value upload_max_filesize 500M
     </If>

以上です。

当初、REQUEST_URIを使用しようと考えましたが
Laravelの場合、index.phpへリダイレクトされるため
REQUEST_URIindex.phpとなり使用できませんでした。

その中で、調べていくとTHE_REQUESTを発見しこちらを使用することにしました。
REQUEST_URIはリクエストのURI部分が取得されるのに対し、THE_REQUESTはメソッドなども含まれるため正規表現で特定のURIに対応させています。

参考

Apache HTTP Serverの変数一覧
<If> ディレクティブ
Overview of new features in Apache HTTP Server 2.4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?