0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[URL正規化] mod_rewriteなどでindex.phpなど簡略化している際に重複コンテンツと判断されないようにSEO対策

Posted at

mod_rewriteなどを使ってURLを簡略化している人は多いと思います。

http://www.example.com/index.php ⇒ http://www.example.com/
http://www.example.com/index.php/login ⇒ http://www.example.com/login
http://www.example.com/index.php/blog/5 ⇒ http://www.example.com/blog/5

しかしこれがよろしくない場合があるらしい。
以前SEO会社から聞いた話だと、表示される内容が同一であっても、検索エンジンではURLが異なる場合は別ページと見なされる可能性がある。
その際に、重複コンテンツと判断されることによりマイナス評価を受ける可能性がある為、検索エンジンにインデックスされているURLを統一し、正規化を図ったほうがいい。
ということらしいです。

以下はその時結局実施しませんでしたが、作った設定です。

.htaccess
  RewriteCond %{HTTPS} off
  RewriteCond %{REQUEST_URI} ^/index\.php
  RewriteRule ^index.php/(.*)$ http://%{HTTP_HOST}/$1 [L,NE]

  RewriteCond %{HTTPS} on
  RewriteCond %{REQUEST_URI} ^/index\.php
  RewriteRule ^index.php/(.*)$ https://%{HTTP_HOST}/$1 [L,NE]

  RewriteCond %{THE_REQUEST} ^.*/index\.php
  RewriteRule .* http://%{HTTP_HOST}/ [L,NE]

HTTPとHTTPSでそれぞれあるので同じページがあるので、HTTPへ統一します。

http://www.example.com/index.php
https://www.example.com/index.php

これらを

http://www.example.com/

に統一。
なんかもっとスマートにする方法があるかもしれないですが、とりあえず目的は果たせます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?