V
V
Valery Gutin2018-04-24 02:07:40
Google
Valery Gutin, 2018-04-24 02:07:40

Is it worth doing a redirect without a slash?

Hello.
I have a site where ~100 pages are indexed and rank highly for topical queries. The problem is that there are a lot of duplicates in the webmaster, pages like: sitename.com/news/ 123/ and sitename.com/news/123 . I don’t have a redirect to a slash, search engines perceive it as two different pages, there are both with and without a slash in the search (the ratio is 30 to 70%).
Is it worth removing the slash through htaccess, and if so, will the pages that were with the slash not fall out?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
I
Igor Karachentsev, 2018-04-25
@alohamneploha

If the advantage is in favor of pages without a slash, then redirect to without a slash. Ideally, it’s worth making it so that only one option works out, in your case it’s without a slash, with a slash it should give 404.
you need to achieve such a result that there is only one option in the issue, otherwise it will be duplicate content

Y
Yana Key, 2018-04-25
@yanakey

If you select the URL option without a trailing slash,
you will need to disable slashes for directories - DirectorySlash Off,
otherwise you will get a circular redirect when accessing them
("page isn't redirecting properly").
With DirectorySlash Off, the DirectoryIndex option inside directories is ignored,
you will need to add mod_rewrite rules up a level to fix it.
At the same time, using mod_rewite inside the directories will not work,
the rules will need to be moved a level higher.

#
RewriteRule ^mydir$ /mydir/index.php [L,E=MYVAR:1]
RewriteCond %{ENV:REDIRECT_MYVAR} !1
RewriteRule ^mydir/$ /mydir [R=301,L]

#
RewriteCond %{REQUEST_URI} ^/mydir
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /mydir/myapp.php [L,QSA]

404 is not worth giving away, 301 is enough for bots from duplicates.

V
Vitaly Arkhipov, 2018-04-24
@arvitaly

Search engines handle 301 redirects quite correctly.
Or you can add the Link-canonical tag. Documentation from google .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question