teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

①、②でpathを分けることを実現させたい

2018/08/29 01:03

投稿

kkkenn
kkkenn

スコア8

title CHANGED
File without changes
body CHANGED
@@ -31,6 +31,13 @@
31
31
  Route::get('/{user}/{repo}/{branch}/{path?}','SearchController@show')->where('path?','.*');
32
32
  このように指定してみたがsyntaxエラー。
33
33
 
34
+ ①だけを通すためなら
35
+ Route::get('/{user}/{repo}/{branch}/{path}','SearchController@show')->where('path','.*');
36
+ Route::get('/{user}/{repo}/{branch}/{path?}','SearchController@show');
37
+ とすればbranch以下のpathに何が来ても(user/repo/branchのような場合でも)通るようになりますが、
38
+ @@@@.@@@のpathが来た時もshowアクションが動くようになってしまいます。
39
+ @@@@.@@@の場合は違うアクションを動かしたいです。
40
+
34
41
 
35
42
  Route::get('/{user}/{repo}/{branch}/{path}','SearchController@show')->where('path','*.*');
36
43
  Route::get('/{user}/{repo}/{branch}/{path}.{ext}','SearchController@show')->where('path','*.*');