![Apache 리디렉션 301 상위 디렉터리가 작동하지 않습니다.](https://linux55.com/image/56693/Apache%20%EB%A6%AC%EB%94%94%EB%A0%89%EC%85%98%20301%20%EC%83%81%EC%9C%84%20%EB%94%94%EB%A0%89%ED%84%B0%EB%A6%AC%EA%B0%80%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
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/