2011-03-11 6 views
0
http://stackoverflow.com/questions/abcd.html&p=1 
http://stackoverflow.com/answers/wxyz.html&p=5 
http://stackoverflow.com/database/mnop.html&p=167 

http://stackoverflow.com/questions/abcd.html?p=1 
http://stackoverflow.com/answers/wxyz.html?p=5 
http://stackoverflow.com/database/mnop.html?p=167 
http://stackoverflow.com/order/anything.html?mode=new 
http://stackoverflow.com/checkout/something.html?mode=old 

다음과 같은 모든 URL을 리디렉션하고 싶습니다.매개 변수가있는 페이지를 리디렉션하는 방법은 무엇입니까?

http://stackoverflow.com/questions/abcd.html 
http://stackoverflow.com/answers/wxyz.html 
http://stackoverflow.com/database/mnop.html 
http://stackoverflow.com/order/anything.html 
http://stackoverflow.com/checkout/something.html 

제발 suugest 해주세요.

+0

리디렉션 기능은 무엇입니까? – occulus

답변

0

? 이 질문에 .htaccess 태그가 붙어 있다고 가정하면 리디렉션을 수행하는 데 사용하려는 것으로 가정합니다.

RewriteRule ^(.*)\?.*$ $1 [L,R=301] 

이 규칙은 기본적으로 형식 *?*에 다음 바로 물음표 이후에 발생하는 모든 내용을 무시 나 모두 주어 말했다.

+0

고마워요,하지만 첫 번째 상황에 대한 코드는 무엇입니까? 그건 저를 혼란스럽게하는 것입니다. – user625118

+0

기술적으로 유효한 URL이 아닙니다. – duncan

0

이 코드
그러나 프론트 엔드 웹 서버에서이 일을 가장 좋은 방법을 시도 (nginx를 e.t.c)

당신은 모든 URL 매개 변수를 제거 할
if (preg_match('@^(.+)\[email protected]', $_SERVER['REQUEST_URI'], $matches)) { 
    header('Location: ' . $matches[1]); 
    exit; 
} 
관련 문제