will_paginate 플러그인을 사용합니다. 나는 (/posts/index/2
대신 /posts?page=2
의) 캐시 할 수있는 경로를 생성하는 오 데르에서레일스가 중복 페이지 캐싱 라우팅 페이지를
나는 내 routes.rb에 다음과 같은 추가 :
map.connect '/posts/index/1', :controller => 'redirect', :url => '/posts/'
map.connect 'posts/index/:page',
:controller => 'posts',
:action => 'index',
:requirements => {:page => /\d+/ },
:page => nil
첫 번째 줄 리디렉션 /posts/index/1
방지하기 위해, 리디렉션 컨트롤러를 사용 /posts/
에 중복 된 페이지가 있습니다.
'posts/index/:page'
규칙을 설정하는 데 문제가 있습니까?
/post/index/
:page
없이 매개 변수가 작동하지 않을 것을 보장 할
:requirements => {:page => /\d+/ }
를 추가 생각했지만,
/posts/index.html
는 캐시지고 있습니다.
/posts/index/
을 /posts/
으로 리디렉션하면 /posts.html
과 /posts/index.html
을 모두 피할 수 있습니까?
감사
UPDATE
는 단순히
map.connect '/posts/index/', :controller => 'redirect', :url => '/posts/'
추가 그리고 더 이상 중복 된 페이지를받지 못했습니다.
그러나 나는 아직도 내가 왜 /posts/index.html
을 얻고 있는지 잘 모르겠다. 이 규칙을보다 간결하게 만드는 방법에 대한 설명이나 제안은 환영합니다;
map.connect '/posts/index/1', :controller => 'redirect', :url => '/posts/'
map.connect '/posts/index/', :controller => 'redirect', :url => '/posts/'
map.connect 'posts/index/:page',
:controller => 'posts',
:action => 'index',
:requirements => {:page => /\d+/ },
:page => nil
고맙습니다. 꼭 시도해보고이 스레드를 업데이트하십시오. – deb