Menu

1 / 2

My Site Had Three Homepages: Killing the Duplicate with Two 301 Rules

DEV Community: php·Mobeen Ahmed·9 days ago
#EHAmNag0
#devto#dev#homepage#index#html
Long article (672 words) — no AI summary yet.
Reading 0:00
15s threshold

For months, my site had three homepages and I had no idea. There was the plain one, the one with www in front of it, and the one ending in /index.html. Same page, same content, three different addresses. A visitor would never notice, but a search engine sees three separate pages fighting over the same content, and that is exactly the kind of quiet problem that costs you rankings without ever showing an error.

I found it the boring way: by typing the variants into a browser and watching what happened. The www version loaded fine. The /index.html version loaded fine. Nothing redirected anywhere. Each one returned a cheerful 200, as if everything was normal. That is the trap — nothing looks broken, so nothing gets fixed, and meanwhile the link value your site earns gets split across three copies of the same page instead of piling up on one.

The fix lives in .htaccess, and it is two rules. The first catches the www host and sends it to the bare domain:

RewriteEngine On RewriteCond % { HTTP_HOST } ^ www \ .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.