
2개의 유사한 경로를 동일한 웹 페이지로 리디렉션해야 합니다.
http://www.domain.com/foo-->http://www.domain.com/ok
http://www.domain.com/foo/bar-->http://www.domain.com/ok
.htaccess에 다음이 있습니다.
Redirect 301 /foo http://www.domain.com/ok
Redirect 301 /foo/bar http://www.domain.com/ok
만약 내가 간다면http://www.domain.com/foo다음으로 이동하면 리디렉션이 작동합니다.http://www.domain.com/foo/bar, 나는 가지고있다http://www.domain.com/ok/bar하지만 작동하지 않습니다. 이 문제를 어떻게 해결하나요?
답변1
순서를 변경해 보세요.
Redirect 301 /foo/bar http://www.domain.com/ok
Redirect 301 /foo http://www.domain.com/ok
mod_rewrite도 참조하세요:
http://httpd.apache.org/docs/current/mod/mod_alias.html
#With mod_rewrite
RewriteEngine on
RewriteRule ^/docs/(.+) http://new.example.com/docs/$1 [R,L]
#With RedirectMatch
RedirectMatch ^/docs/(.*) http://new.example.com/docs/$1
#With Redirect
Redirect /docs/ http://new.example.com/docs/