F
F
FronzZ2021-04-23 14:47:07
htaccess
FronzZ, 2021-04-23 14:47:07

How to remove duplicate pages in this case through 404 or redirect???

Hello! If someone understands, can you tell me whether the general structure that removes duplicate pages is adequately made for me? I don't know much about this myself.

ErrorDocument 404 /err404.php
RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^index$|\.php - [L,R=404]

RewriteRule ^([^.?]+)$ %{REQUEST_URI}.php [L]


Introductory information: I have a domain without www., I indicated all links in my html code without a slash at the end and without php.

A number of questions that make me think:

1) If you add a slash on the main page site.ru/ then there is a redirect to the page without this slash site.ru (apparently hosting settings or something), but if you add to site.ru/book/pushkin slash at the end -> (site.ru/book/pushkin/) there is a 404 error, is it needed here or should I use a redirect again?
2) When adding /index.php on the main page, 404 comes out, also when adding url .php at the end (or it’s better to do a redirect in this case, because there are physically files with this ending, this ending is not in the links themselves in a php document.) when you add any character at the end, a letter or a phrase, 404 also comes out.
3) From www there is a redirect to without site.ru

I would be glad if you tell me, or even better show how you can change it more correctly (maybe from the point of view of seo, because I read that it is better to use redirects than 404, which raises questions), or leave it as it is because the code is adequate.

PS I understand the question is a bit strange, but I'm confused and trying to figure it out. I would be grateful if you can help!
If you need any additional information, then I will add it.
Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
John Didact, 2021-04-23
@JohnDidact

R=404??? Redirect with code 404?) 404 - this means that the document was not found. In your case, it is found, but has different addresses. Therefore, it would be more logical to send a 301 redirect from all addresses of the document to its canonical address.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question