Last active
January 2, 2016 06:29
-
-
Save mikanmarusan/8264092 to your computer and use it in GitHub Desktop.
Apacheでphp以外のファイルでもphpを実行する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Apacheでphp以外のファイルでもphpを実行する方法 | |
# 1) MIME Typeをいじる方法 | |
# CGIやPHPモジュールへの処理渡しは、MIMEタイプに対しても定義されているのでこの方式が使える | |
# .phpと.htmlの場合はPHPとして実行する | |
AddType application/x-httpd-php .php .html | |
# 2) AddHandlerで関連づける | |
# 拡張子 .phpと.htmlのファイルをハンドラ application/x-httpd-php に関連づけする | |
# (注意) SetHandler は通常 <Directory> や <Location> ブロックの中で使用し、 | |
# <Directory> や <Location> にあるファイルを拡張子にかかわらず全てハンドラに結びつけるディレクティブ | |
AddHandler application/x-httpd-php .php .html | |
# 3) ForceTypeでやんちゃする | |
# ForceTypeはマッチする全てのファイルについて指定の MIME コンテントタイプで 送られるようにする | |
# ので <Directory> <Location> <File> などで適切に範囲を絞るべき | |
<Location /my-script> | |
ForceType application/x-httpd-php | |
</Location> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment