/ /マスク発信リンク - PHP、.htaccess、ダウンロード

マスクの発信リンク - PHP、.htaccess、ダウンロード

PHPのWebページで、html5プレーヤーを表示していますmp3トラックを再生し、その横にダウンロードボタンがあります。ダウンロードリンクのみを隠したいので、訪問者は自分のサーバーのディレクトリツリーを見ることができません(www.example.com/content/plugins/私のサーバのフォルダ構造を変更することなく、(www.example.com/download/test.mp3)のようにもっとシンプルで小さなものへのリンクを変更したいと思います。

.htaccessかPHPのものかどうかわかりません。

前もって感謝します。

回答:

回答№1は2

.htaccess 次の書き換えルールが必要です。

$ pwd
/var/www
$ cat .htaccess
RewriteEngine on
RewriteRule ^/download/(.*.mp3) /content/plugins/audio/downloads/$1 [NC]

それはすべてにマッチします http://yourdomain.com/download/….mp3 リクエストとリダイレクト http://yourdomain.com/content/plugins/audio/downloads/….mp3

.htaccessをサブディレクトリの内側から操作したい場合は、 RewriteBase

$ cat subdirectory/.htaccess
RewriteEngine on
RewriteBase /subdirectory
RewriteRule ^download/(.*.mp3) content/plugins/audio/downloads/$1 [NC]

すなわち、 http://yourdomain.com/subdirectory/download/….mp3http://yourdomain.com/subdirectory/content/plugins/audio/downloads/….mp3