いくつかの直接リクエストをカスタム スクリプトにマップする必要があります。
somesite.com/getfile/file_name.xxx
somesite.com/getfile/type1/file_name.xxx
somesite.com/getfile/type2/file_name.xxx
somesite.com/getfile/type3/file_name.xxx
このタスクを達成するために、次のルールで .htaccess を作成しました。
RewriteEngine On
RewriteRule ^getfile/(.*)/(.*) /script_path/getfile/file.php?pn=$2&type=$1 [L,NC]
RewriteRule ^getfile/(.*) /script_path/getfile/file.php?pn=$1 [L,NC]
すべて正常に動作しているように見えますが、次のような URL を呼び出すと:
somesite.com/test_path/other/getfile/test.php
この URL はfile.php
スクリプトにリダイレクトされます。
ドメイン名の直後に getfile で始まるパスだけをスクリプトに送信する必要があります。
somesite.com/getfile -> need to be redirected
somesite.com/test_path/other/getfile/ -> must not be redirected
サイトのフォルダー構造
/
|_www
|_serverRootFolder (the .htaccess file here, this is the apache serverRoot is www.somesite.com/)
|_script_path