0 レビュー
0 回答
php-htaccessは未使用のものを配列に分割します
私がすでに達成したこと。
次のURLがあるとしましょう:
www.example.com/api
->www.example.com/api/index.php
私が行うすべてのエンドポイント(ここではfoo )があり、次のようになります。
www.example.com/api/foo
foo->www.example.com/api/index.php?controller=foo&action=
このURLは私の「Foo-Controller」にアクセスします。次に、実行するアクションを渡します。
www.example.com/api/foo/bar
bar->www.example.com/api/index.php?controller=foo&action=bar
これにより、「Foo」コントローラーのメソッド「bar」が呼び出されます。
問題:
www.example.com/api/foo/bar
すべてを配列として提供したいと思います。
例:
www.example.com/api/foo/bar/some/dummy/variables
>www.example.com/api/index.php?controller=foo&action=bar¶ms[]=some¶ms[]=dummy¶ms[]=variables
参考(私が持っているもの)
これが私の現在の.htaccess
ファイルです:
# Turn rewrite engine on
Options +FollowSymlinks
RewriteEngine on
# Define Paths
RewriteRule "^([a-zA-Z0-9]+)$" "index.php?controller=$1&action=" [qsa]
RewriteRule "^([a-zA-Z0-9]+)/([a-zA-Z0-9]+)$" "index.php?controller=$1&action=$2" [qsa]
これには最初の2つの例が含まれていますが、3番目の例がありません。
わからない
同様の質問
私たちのウェブサイトで同様の質問で答えを見つけてください。