2013-07-19 3 views
0

I는 내가 할 때, 어떤 의미포함 GET 노선의 매개 변수 및 프레임 .html 중에서 페이지

을 GET을 통해 데이터를 제출 양식을 가지고 : example.com/Searches/results?search=asdadasdasd

:

echo $this->Form->create('Search', array('type'=>'get', 'url'=> array('controller'=>'searches','action'=>'results'))); 
echo '<div class="search-box">'; 
echo $this->Form->input('search', array(
    'class' => 'search-input', 
    'placeholder' => 'Search Domain Names', 
    'label'=>false)); 
echo $this->Form->input('', array(
    'class' => 'search-icon', 
    'label' => false, 
    'type' => 'submit' 
    )); 
echo $this->Form->end(); 
    ?> 

내가 같은 URL을 얻을

나는 경로를 프레임 할 같은 나는 다음과 같은 URL 얻을 :

example.com/search/asdadasdasd.html

http://book.cakephp.org/2.0/en/development/routing.html#file-extensions

하지만, 어떻게 내부 쿼리를 검색 얻을 것이다 : 나는 어떻게 확장을 가야 http://book.cakephp.org/2.0/en/development/routing.html

:

나는 한 번 봐했다? 이 검색어에 대해 알고하지 않는 형태를 생성 할 때

감사

CakePHP의 자체 불가능

답변

0

, 그것은 제출할 때 이렇게 동적으로 수행되어야 할 것이다 이러한 URL을 생성, 아직 존재하지 않기 때문에 양식, 즉 JavaScript가 필요한 사용자 측.

가장 쉬운 방법은 서버 쪽 URL rewriting을 사용하는 것입니다. 여기

는 URL의 경로가 /searches/results가 (모두, 경로 및 쿼리 문자열을 처리하는 일치는 search 키의 쿼리 문자열을 테스트하고 경우에 리디렉션에 대한 값을 사용합니다 ( app/webroot/.htaccess에서 잘 작동합니다) 예입니다 대소 문자 구분) : 이것은 /searches/results?search=whatever 같은 /search/whatever.html에 URL을 다시 것

RewriteCond %{QUERY_STRING} ^search=(.*)$ [NC] 
RewriteRule ^searches/results$ /search/%1.html? [NC,R=302,L] 

.

+0

정말 빨랐어 요! 나는 늦었다. 승인! 네, 시도하겠습니다. – Karma