이전 웹 사이트 구조는 example.com/wp
이었습니다. 나는이 후크Wordpress 미디어 첨부 파일 페이지를 루트 위치로 리디렉션
add_action('template_redirect', 'wpsites_attachment_redirect');
function wpsites_attachment_redirect(){
global $post;
if (is_attachment() && isset($post->post_parent) && is_numeric($post->post_parent) && ($post->post_parent != 0)) :
wp_redirect(get_permalink($post->post_parent), 301);
exit();
wp_reset_postdata();
endif;
}
을 사용하고
example.com/wp/image1 ====> example.com/image1
: 나는 (301) 내 모든 미디어 첨부 페이지 같은 (1500 페이지) 리디렉션 wp_redirect
를 사용하는 것을 시도하고있다 그래서 지금 example.com
로 이동 한
그리고 아이디어는 wp_redirect(example.com/>Any attachment link here<, 301);
(그것은 다른 두 사람의 답변 혼합이다). 후크가 좋을 것입니다. –
Mrjack @hope이 도움이 될 것입니다. –