B
B
Borankin2020-08-08 01:19:09
PHP
Borankin, 2020-08-08 01:19:09

Redirecting from domen.com/public to domen.com via .htaccess does not work. How to set rel="canonical" for domain.com/?

Hello!
There is a site on Laravel 5.7. And like many people have the problem of duplicate pages (domen.com/public/post and domen.com/post are the same pages). Site on virtual hosting. As soon as I didn’t change the .htaccess file (both in the root and in the public folder, I shoveled a bunch of sites in search of information. That’s all it doesn’t help.
I want to configure adding the link rel="canonical" tag to domen.com/post pages. To at the same time, it was not registered on the domen.com/public/post pages. It is necessary to get away from duplicating pages somehow.
As far as I understand, it is necessary to go in the following direction.
In the current url of the page, check for the presence of public and if it is not there, then add a tag with canonical. If there is public, then don't add it.I don't know how to implement it in php.Probably check it through regular expressions.
Sorry for such reasoning, I'm still just learning.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2020-08-08
@Sanes

Сайт на виртуальном хостинге.
For this, there is technical support from the hosting provider. On different servers, the behavior of .htaccess is different.

P
Puma Thailand, 2020-08-08
@opium

So Laravel does not have such problems, how many sites on it I have, none of them have such a problem, why are you duplicating posts there?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question