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 3 years have passed since last update.

url正規化 index.htmlをアリにする場合

Last updated at Posted at 2020-05-13

RewriteEngine on

#TOPページの処理
RewriteRule ^$ https://example.jp/index.html [R=301,L]

#下層ページの処理
#ただし/xxxxxxxx/のURLは除外
RewriteCond %{THE_REQUEST} !^./xxxxxxxx/
RewriteCond %{THE_REQUEST} ^.
/
RewriteRule ^(.*)/$ https://example.jp/$1/index.html [R=301,L]

#合算
RewriteEngine On
RewriteRule ^$ https://%{HTTP_HOST}/index.html [R=301,L]
RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1/index.html [R=301,L]

httpsリダイレクト

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

wwwありに統一
RewriteEngine on
RewriteCond %{HTTP_HOST} ^dev.planet.jp$
RewriteRule ^(.*)$ https://www.dev.planet.jp/$1 [R=301,L]

wwwなしに統一
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.url\.com)(:80)? [NC] RewriteRule ^(.*) http://url.com/$1 [R=301,L]
http://www.url.com/」にアクセスされたら「http://url.com/」にリダイレクトする記述です。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.example.jp) [NC]
RewriteRule ^(.) https://example.jp/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.
)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

・RewriteEngine on:書き換えを開始するぜ!!
・RewriteCond:書き換えする対象(条件)はこれだぜ!!
・RewriteRule:書き換え内容はこれだぜ!

トレイリングスラッシュをなしにする。
でもループしちゃった。
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)/+$ $1 [R=301,L]

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?