Error while redirecting in Codeigniter
<p>I want to have my post title in my url, separated with dashes and I do that with <a href="https://stackoverflow.com/a/11001824/6277870">this answer</a> and this is my code : </p>

<pre><code> public function post($post_id, $slug = ''){
    $data['post'] = $this-&gt;posts_model-&gt;get_post_by_id($post_id);
    if ($slug) {
        $get_title = $data['post']-&gt;post_slug;
        redirect('blog/' . $post_id . '/' . $get_title);
    }
    $this-&gt;load-&gt;view('pages/show-post', $data);
}
</code></pre>

<p>and these are my routes :</p>

<pre><code>$route['blog/(:num)'] = 'blog/post/$1';
$route['blog/(:num)/(:any)'] = 'blog/post/$1/$2';
</code></pre>

<p><strong>Problem :</strong> when I load my <code>example.com/blog/1</code> everything is ok, but when I load <code>example.com/blog/1/anything</code> my code redirect me to <code>example.com/blog/1/my-slug-from-database</code> successfully but page load failed and firefox show me <code>The page isn't redirecting properly</code> error.</p>

<p>How can I solve this problem ? Is there any problem in my code ?</p>

<p>Thanks for your helps !</p>