S
S
SONce2015-03-26 02:15:04
CodeIgniter
SONce, 2015-03-26 02:15:04

How to remove double trail slash in CodeIgniter?

I noticed that on my site which is on CI there is such a problem:
there is a foo controller, the
site.ru/foo/bar.html link leads
to it, but you can also access it through
site.ru // foo/bar.html
how to make the second the address gave 404?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Entelis, 2015-03-26
@DmitriyEntelis

1. There is an opinion that in canonical it is better to write an absolute link along with the domain
2. We made a rather "stupid" solution in each controller:

$app->vars->seo->canonical = ... ; //определяем ссылку

...

if (isset($app->vars->seo->canonical) && ($_SERVER['REQUEST_URI'] != $app->vars->seo->canonical) )
{
  header('HTTP/1.1 301 Moved Permanently');
  header('Location: '.$app->vars->seo->canonical);
  die();
}

This is probably not very beautiful, but taking into account the fact that the SEOs send their Wishlist regularly, I don’t see the point in fencing something more unified.

N
Nazar Mokrinsky, 2015-03-26
@nazarpc

You don’t need to worry about it at all, just indicate the path of the page in the canonical meta tags, and everything will be fine with you.
Here is the first thing I found about this: moz.com/blog/canonical-url-tag-the-most-important-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question