CodeIgniter Forums
issue for rewrite link in multilang site - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: issue for rewrite link in multilang site (/thread-78663.html)



issue for rewrite link in multilang site - eleumas - 02-22-2021

Hi! I have this controller:
PHP Code:
public function article($slug)
  {
    $data['article'] = $this->articlesModel->where('slug'$slug)->first();
    $dataArticle $data['article'];
    $data['title'] = $dataArticle['meta_title'];
    $data['metaDescription'] = $dataArticle['meta_description'];

    return view('article'$data);
  

This link in categories view:
PHP Code:
<?php $slug $a['slug'];?>
<a href="<?php echo base_url('en/'.$slug);?>" target="_blank">
<?php echo $a['heading'];?>
</a> 

And this (wrong) route:
PHP Code:
$routes->add('(:any)/it/(:any)''It/Main::article/$1'); 

What is the solution for open the article page with link: mysite.com/en/article-slug and not have 404 or a link like mysite.com/en/article/article-slug?

Thanks for the support!