| 제목 | 리다이렉션 후 url이 [::1] 이렇게 바뀌는이유가 멀까요? | ||
|---|---|---|---|
| 글쓴이 | 정수리 | 작성시각 | 2016/05/25 09:18:22 |
|
|
|||
|
간단한 게시판 비슷하게 만들었습니다. 게시글을 등록하면 자기 등록한 게시글로 리다이렉션 시키는데 url의 형태가 변경되네요;; 원래는 localhost/index.php/....인데 [::1]/index.php/...요렇게 바뀌네요;;
[::1] 의미와 왜이렇게 되는지 알수있을까요??; 밑에 redirect 부분은 저렇게 사용하였습니다.
function add(){
$this->_head();
$this->load->library('form_validation');
$this->form_validation->set_rules('title', '제목', 'required');
$this->form_validation->set_rules('description', '본문', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('add');
}
else
{
$topic_id=$this->topic_model->add($this->input->post('title'), $this->input->post('description'));
$this->load->helper('url');
redirect('/topic/get/'.$topic_id);//사용자를 리다이렉션 시켜줌
echo '성공';
}
$this->load->view('footer');
}
function del($id){
$this->_head();
$result=$this->topic_model->del($id);
$this->load->helper('url');
if($result){
redirect('/topic');
}else{
echo "<script>location.href='/topic/get/$id'</script>" ;
}
$this->load->view('footer');
}
|
|||
| 다음글 | redirect가 이상해요;; (6) | ||
| 이전글 | 코드이그나이터 image 호출 경로 에러..? (3) | ||
|
강발자
/
2016/05/25 10:51:10 /
추천
0
|
|
정수리
/
2016/05/25 11:21:17 /
추천
0
값을 주면 redirec시 url경로가 이상하게 잡혀서 오류가 발생하네요;; 그냥 순수하게 localhost가 나오게 하고싶은데 ㅜ.ㅜ |
|
kaido
/
2016/05/25 11:27:01 /
추천
0
정 안되시면
redirect(base_url().'/topic/get/'.$topic_id);
or
redirect('http://localhost/topic/get/'.$topic_id);
|
|
정수리
/
2016/05/25 13:28:16 /
추천
0
@kaido 감사합니다 말씀하신대로 하여 잘해결되었습니다. |
위 문제는 config.php에서 $config['base_url']를 빈칸으로 해두었을 경우 나타납니다.
$config['base_url']의 값을 셋팅하지 않았을 경우 Codeigniter가 프로토콜과 경로를 추측하는 과정에서 [::1]가 튀어 나온거 같습니다.
$config['base_url'] = 'http://example.com/'; 처럼 URL 값을 넣어줘보세요~