.htacsess リダイレクト サンエツ

サンエツ

この方法で合っているかわからんが、とりあえずリダイレクト設定をした。すでにインデックスされている旧ページで克つ、不要なページは関連する新ページにリダイレクトさせた。茶谷さんがwordpressで作った旧サイトとカートシステムはサーバーからは削除しない事。

/wp
/shop

 

リダイレクト参照ページ

特にこの箇所

ディレクトリ単位のリダイレクト

「old」ディレクトリにアクセスがあった際、「new」ディレクトリに転送をかけたい場合の記述です。

ディレクトリ以下にファイルがある場合は、newでもファイルを置いておかないと404エラーになってしまいます。


RewriteEngine on
RewriteRule ^old(.*)$ /new$1 [L,R=301] 

 

今回の作業のポイント

・httpにアクセスがあってもhttpsにリダイレクト


・茶谷さんが作ったページでインデックスされちゃっているディレクトリを新ページへリダイレクト

・外部サイトのカラミーへのリダイレクト

・茶谷さんが作ったカートシステムの/shop の中にも.htaccessを別個にそれ用として設置
※.htaccessは階層がちがえばたとえ上部階層に.htaccessがあっても同じディレクトリに入っている.htaccessを参照する。

.本当は不要な記述かもしれないけど茶谷さんが作っているwordpressコンテンツに悪さしないようにwordpress関連の.htaccess記述はそのままにする。

編集ファイルは /リダイレクト用/サイトチェンジ後 にある。

ルート直下に.htacess設置↓

AddHandler application/x-httpd-php53 .php

RewriteEngine On

httpsにリダイレクトさせる 。ブリカマはhttpのままだがこの設定でも大丈夫↓
# http->https Redirect 
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Main RewriteRule for multidomain. httpをhttpsと変更させる
RewriteCond %{HTTP_HOST} ^(sanetsu.com)
RewriteCond %{REQUEST_URI} !^/(sanetsu.com)/
RewriteRule ^(.*)$ https://www.sanetsu.com/$1 [L]

# Redirect 各コンテンツのリダイレクト設定

# Redirect
RewriteRule ^gift(.*)$ /goods$1 [L,R=301]
RewriteRule ^showroom(.*)$ /tenpo$1 [L,R=301]
RewriteRule ^contact(.*)$ /inquiry$1 [L,R=301]
RewriteRule ^policy(.*)$ /privacy$1 [L,R=301]
RewriteRule ^goodslabo/scene(.*)$ /index.html$1 [L,R=301]
RewriteRule ^goodslabo(.*)$ /index.html$1 [L,R=301]
RewriteRule ^online(.*)$ https://sanetsu.shop-pro.jp [L,R=301]
RewriteRule ^category/news(.*)$ /sanetsu-information/category/news$1 [L,R=301]
RewriteRule ^category/blog(.*)$ /sanetsu-information/category/blog$1 [L,R=301]
RewriteRule ^category/press(.*)$ /sanetsu-information/category/press$1 [L,R=301]
RewriteRule ^category/giftitem/gift(.*)$ /sanetsu-information/category/giftitem/gift$1 [L,R=301]
RewriteRule ^shop(.*)$ https://sanetsu.shop-pro.jp [R=301,L]
RewriteRule ^goodsitem(.*)$ /index.html$1 [L,R=301]
RewriteRule ^giftitem(.*)$ /index.html$1 [L,R=301]
RewriteRule ^news(.*)$ /sanetsu-information/category/news$1 [L,R=301]

ErrorDocument 404 https://www.sanetsu.com

# Main RewriteRule for multidomain. ブリカマはSSLしないのでそのまま変更なし↓
RewriteCond %{HTTP_HOST} ^(www.burikama.com)
RewriteCond %{REQUEST_URI} !^/(www.burikama.com)/
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1/ [L]

# Main RewriteRule for multidomain.
RewriteCond %{HTTP_HOST} ^(burikama.com)
RewriteCond %{REQUEST_URI} !^/(burikama.com)/
RewriteRule ^(.*)$ http://www.burikama.com/$1 [L]

# BEGIN WordPress 一応残しておく↓
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

 

shop (茶谷さんカート)下に.htaccess設置↓

RewriteEngine On

RewriteRule gift.php$ https://www.sanetsu.com/goods/index.html
RewriteRule ^(.*)$ https://sanetsu.shop-pro.jp/

[R=301,L]

 

 

 

旧ページのいらない物をgoogleインデックスから削除するためにインデックス削除申請。

 

 

 

不要なページをクローラーされないようにrobots.txtをアップ

User-agent:*
Disallow: /giftlabo/
Disallow: /shop/
Disallow: /wp/
Disallow: /giftitem/
Disallow: /goodsitem/

 

リダイレクト .htaccess

https://ferret-plus.com/2186

 

.ページ単位のリダイレクト

「old.html」にアクセスがあった際に「http://www.example.com/new.html」へ301リダイレクトさせる記述です。


RewriteEngine on
RewriteRule ^old.html$ http://www.example.com/new.html [L,R=301] 

Lは「この処理はここで終わり(LAST)」の意味で、R=301は「301リダイレクトをしなさい」という指定になります。

ちなみに、Rだけだと302リダイレクトになるので、301リダイレクトを行いたい場合は必ずR=301の指定をするようにしてください。

2-2.ディレクトリ単位のリダイレクト サンエツ↓

「old」ディレクトリにアクセスがあった際、「new」ディレクトリに転送をかけたい場合の記述です。

ディレクトリ以下にファイルがある場合は、newでもファイルを置いておかないと404エラーになってしまいます。


RewriteEngine on
RewriteRule ^old(.*)$ /new$1 [L,R=301] 

2-3.http→https のリダイレクト

HTTPアクセスされたページをSSLでリダイレクトをする方法です。SSLを使いたいディレクトリに以下を記述したファイルを入りします。

GoogleがSSL化を推奨していることもあり、SSL対応を行う人も増えていますが、この場合もHTTPでのアクセスをHTTPSにリダイレクトしたほうが良いです。


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

 

 

 

 

 

 

 

https://www.itti.jp/web-design/htaccess-redirect/

 

URLが大幅に変わる

ドメイン、ディレクトリ、ページ全てが変わる場合は下記になります。

.htaccess

RewriteEngine on
RewriteRule https://www.old.com/old/old.html https://www.new.com/new/new.html [R=301,L]

//下記の方法でも可能
RewirteEngine on
Redirect permanent https://www.old.com/old/old.html https://www.new.com/new/new.html

 

https://sem-journal.com/seo/how-to-redirect/

 

ジェネレーター

https://htaccess.cman.jp/explain/redirect.html

 

グローバルサイン SSL ブラウザに 保護されていない通信 とでる  中尾清月堂

中尾清月堂をSSLにするためにグローバルサインのクイック証明を契約。

グローバルサイン社はSSLディレクトリは不要でhomeに置くとSSLが機能する。

 

しかし、ブラウザではhttpsでアクセスしても 保護されていない通信とでる。google serch consoleからクロールリクエストだしても同じ状態。

SuieXのサポートセンターに問い合わせると、コンテンツの中にhttpで始まる記述がhttpsと混在しているからhttpsにしなさいとのことでトップページ内を修正したが変わらない。サポートにつたえると証明書は表示できるからサイト構築自体の問題だとばっさり。

サイト内のhttpをhttpsに変更。

※注意 CGIやスクリプト内のそもそもhttpが記述してある場合はそのままにしておかないと動作しなくなるからそっとしておく。

 

一応全部のコンテンツページに表記してあったhttpをhttpsに変更してアップ。google serch consoleからクローラー要請。.htaccsessでhttpにアクセスしたらhttpsにリダイレクト設定で大丈夫になった。

あと、証明書が設置されて問題解決まで上記の事やったのが3日間かかったがその間でサーバー側の設定が定着した?っていうことはなかろうか。申請から3日間すったもんだしたが一応問題から解決までそのくらいかかった。

//////////////

httpからhttpsへのリダイレクト

httpからhttpsへリダイレクトするには.htaccessに下記を追加します。

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

これにより、例えば「http://example.com」というURLでアクセスすると「https://example.com」にリダイレクトされます。

下層ページも同じで、ドメイン以下同じURLでページがある場合は「http://example.com/content1」というURLでアクセスすると「https://example.com/content1」にリダイレクトされるということです

 


以下、サポートのやり取りメール

 

 

コンタクトセンター (NTTPC)

2020/07/15 11:31 JST

コンタクトセンターよりご案内いたします。

本件、確認いたしましたが、
証明書につきましては正常に設定が完了している状態とお見受けいたします。

httpがhttpsと混在しないようにソースを修正していただき、なお表示が不可の場合、
サイト構築が影響している可能性がございます。

恐れ入りますが、弊社サイト構築につきましてはサポート対象外になります。
お客さまにてご確認くださいますようお願いいたします。

以上、よろしくお願いいたします。

——————————————————————–
株式会社 NTTPCコミュニケーションズ
WebARENA コンタクトセンター

サポートサイト
https://help.arena.ne.jp/hc/ja
——————————————————————–

 

 

コンタクトセンター (NTTPC)

2020/07/14 18:17 JST

コンタクトセンターよりご案内いたします。

本件、確認のうえ回答いたします、
確認にお時間をいただき申し訳ございませんが、
回答まで今しばらくお待ちくださいますようお願いいたします。

以上、よろしくお願いいたします。

——————————————————————–
株式会社 NTTPCコミュニケーションズ
WebARENA コンタクトセンター

サポートサイト
https://help.arena.ne.jp/hc/ja
——————————————————————–

 

 

吉田孝

2020/07/14 14:20 JST

ご返信ありがとうございます。

httpがhttpsと混在しないようにソースを修正していますが

変わらず httpsが表示されないです。

例えば、https://nakaoseigetsudou.jp/index.html

のソースの中にはhttp はありません。htmlのソース内の絶対パスはhttpsになっています。

しかしながら セキュリティーの保護なし と表示されます。

 

ご確認お願いいたします。

 

吉田

 

 

 

 

コンタクトセンター (NTTPC)

2020/07/14 13:22 JST

コンタクトセンターよりご案内いたします。

確認いたしましたところ、お客さまのコンテンツの記述にて
httpから始まるURLとhttpsから始まるURLが混在しているように見受けられます。

httpとhttpsの記述が混在している場合、
ご利用しているブラウザにてhttpsの表示が正常にされない場合があります。
恐れ入りますが、index.htmlの記述をご確認くださいますようお願いいたします。

以上、よろしくお願いいたします。

——————————————————————–
株式会社 NTTPCコミュニケーションズ
WebARENA コンタクトセンター

サポートサイト
https://help.arena.ne.jp/hc/ja
——————————————————————–

 

 

吉田孝

2020/07/13 17:24 JST

グローバルサイン社のクイック認証でSSL契約をしたのですが、homeにあるコンテンツが未だにchromeなどのブラウザに 【保護されていない通信】とでてしまっています。webarenaからのメールにはssl証明書を取得し設定完了しましたとなっています。【保護されていない通信】のメッセージをなくすにはどうしたら良いですか?

添付ファイル
sample.jpg

リダイレクト NOT FUND404 の時の方法 センティアサイト .htaccess

※404は使わずに301を使うようにと指導されたので下記の方法は使わない。301の方法を用いる。下記

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.yoga-union.jp [R=301,L]

 

一応404対応したいなら下記。

 

 

https://allabout.co.jp/gm/gc/23770/2/

センティアで実施

  1. 移転案内を掲載したページを1つ用意 (moveinfo.htmlなど)
  2. 「404 Not Found」エラーの際にはそのページが表示されるよう.htaccessを記述
  3. サイト内の全ページを削除 (※一部だけを移転するなら、移転する分だけを削除)

上記のようにすると、(全ページが削除されているため)サイト内のどのURLにアクセスしても「404 Not Found」エラーが表示されるようになります。その「404 Not Found」エラーが「移転案内」になっているので、結果として、「サイト内のどのURLにアクセスしても移転案内が表示される」ことになります。

具体的な作業手順は以下の通りです。

1. 移転案内を掲載したページを1つ用意 (moveinfo.htmlなど)
例えば「moveinfo.html」などのファイル名で、移転案内を掲載したページを用意します。このファイルは、ウェブサイト内の最上階層(トップページがあるディレクトリ)にアップロードしておきます。

2. 「404 Not Found」エラーの際にはそのページが表示されるよう.htaccessを記述
「.htaccess」ファイルに、以下の1行を記述します。これは、404エラーが発生した際には最上階層にある「moveinfo.html」を表示させるようにする記述です。

ErrorDocument 404 /moveinfo.html

※「/moveinfo.html」の部分は、先ほど作成したファイル名を指定します。何でも好きな名称で構いません。先頭の「/」記号を忘れないよう注意して下さい。なお、最上階層以外のディレクトリ(フォルダ)に置いた場合は、ディレクトリ名も加える必要があります。ここでは絶対パスで記述する必要があり、相対パスで書いてはいけません。

3. 404エラーの表示確認
存在しないページをブラウザで表示させてみて下さい。そこで、通常の「404 Not Found」エラーメッセージではなく、移転案内を書いた独自ページ(moveinfo.html)が表示されればOKです。表示されない場合は、記事「Not Foundなど エラーメッセージを独自作成」の5ページ目にある「うまくいかない場合の原因と解決方法」をご参照下さい。

4. 全ページを削除
最後に、ウェブサーバ上にあるすべてのHTMLファイルを削除します。これによって、どのページにアクセスしようとしても「404 Not Found」エラーが出るようになります。つまり、どのページにアクセスしても、同じ移転案内が表示されるわけです。

自動移動機能を加えるには
上記の方法だと、全ページに一括して移転メッセージを表示できますが、その後の自動転送は行われません。メッセージを表示した後に自動転送を行いたい場合は、次のページ以降でご紹介する、HTMLやJavaScriptを使って自動転送する方法と組み合わせて下さい。

※次のページでご紹介する「HTMLのmeta要素を使う方法」だと、パス名(URLの構造)を維持した状態での移動ができません。パスを維持して転送したい場合は、最後のページでご紹介する「JavaScriptを使って自動転送する方法」と組み合わせて下さい。

それでは次に、HTMLのmeta要素を使って自動移動(リダイレクト)する方法をご紹介いたします。

 

センティアで実施

● /.htaccess  に下記表記

ErrorDocument 404 /move.html

 

●リダイレクト用のファイルとindex.htmlに下記表記してルート下に設置

(index.htmlにも記さないとhttp://centia.jpでアクセスされるとnot fundになるから)

<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>ページ移設</title>
<style type=”text/css”>
h2 {
text-align: center;
margin-top: 100px;
}
</style>

<!–リダイレクト–>
<meta http-equiv=”refresh” content=”2;URL=https://centia.jp/”>

</head>

<body>

<h2>インドアテニスククール センティアのwebサイトは移転いたしました。</h2>
<h2> 自動で新サイトへ移ります。 </h2>
</body>
</html>

 

google serch console ドメイン「www」あり・なしの統一設定をしてみる

https://resound-weblab.com/log/archives/1004

suitexで子ドメインwwwを設定して、wwwを優先するために
ルート直下の.httaccessに

wwwアリの場合

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(besthome-web.net)(:80)? [NC]
RewriteRule ^(.*) http://www.besthome-web.net/$1 [R=301,L]
order deny,allow

 

wwwなしの場合

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.megane-house.net)(:80)? [NC]
RewriteRule ^(.*) http://megane-house.net/$1 [R=301,L]
order deny,allow

 

 

https://support.google.com/webmasters/answer/44231

 

※マルチドメインではどう記述すれば良いかわからない。

 

 

マルチドメインサイトではパーマリンクのカスタム構造では404する問題を解決する方法

カスタム投稿にするとblog投稿が404になった。

 

http://control.shado.jp/2010/0930112537.html

 

原因はSuiteX下でのマルチドメインが原因。マルチドメインツールによるhome直下の.htaccessで一度mod_rewriteしているため、WordPressが生成した.htaccessが無視されるからだ。WordPressはindex.phpでページを動的生成するので、これを希望どおり挙動させるためには、home直下の.htaccessでindex.phpにリダイレクトすればよい(末尾)。

ソースを表示

# This file is made by RewriteRule Tool.

# Enable RewriteEngine.
RewriteEngine On

# Main RewriteRule for multidomain.
RewriteCond %{HTTP_HOST} ^(www.yoga-union.jp|yoga-union.jp)
RewriteCond %{REQUEST_URI} !^/(www.yoga-union.jp|yoga-union.jp)/
RewriteRule ^(.*)$ /%{HTTP_HOST}/$1/index.php [L]

 ※これやるとwordpressはだいじょうぶなのだが、http://www.yoga-union.jpにアクセスするとNot Found となってしまうのでできない!!

 上記の状態だとドメイン名だけでブラウザに入力した際にindex.htmlには行かずindex.phpを見つけにリダイレクトするのでNot Foundとなってるようで、それを解決する為にhttp://www.yoga-union.jp/index.htmlと同じ内容のindex.phpを作り、index.htmlと同じ場所に置いたら表示された。これでwordpressとドメイン名だけでもどちらも表示される。

http://www.yoga-union.jp/index.php

 

 

マルチサイトのほうの.htaccessには下記を表記

AddHandler application/x-httpd-php53 .php

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /kanazawa/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /kanazawa/index.php [L]
</IfModule>

# END WordPress

ギャラリーサク&next door サイトクローズ

サイトクローズ準備の為に、サイトにアクセスしたらクローズのお知らせページへリダイレクト設定をした。

●ギャラリーサク リダイレクト

<Files ~ \”^.(htaccess|htpasswd)$\”>
deny from all
</Files>

Redirect permanent /index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/event/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/menu/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/paticular/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/recomendation/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/example/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/new/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/process/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/wind/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/taste/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/attraction/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/light/index.html http://gallery-saku.jp/close.html
Redirect permanent /info/index.html http://gallery-saku.jp/close.html
Redirect permanent /inquiry/index.html http://gallery-saku.jp/close.html
Redirect permanent /nousaku/index.html http://gallery-saku.jp/close.html
Redirect permanent /plus1/index.html http://gallery-saku.jp/close.html
Redirect permanent /privacy/index.html http://gallery-saku.jp/close.html
Redirect permanent /saku_blog/ http://gallery-saku.jp/close.html

order deny,allow

 

 

●ネクストドア リダイレクト

<Files ~ \”^.(htaccess|htpasswd)$\”>
deny from all
</Files>

Redirect permanent /index.html http://nextdoor2010.jp/close.html
order deny,allow

301リダイレクト(同一ドメイン内)の設定方法:「.htaccess」の書き方

http://yakugakusuikun.com/9805.html

 

リダイレクト生成ツール

 

<Files ~ \”^.(htaccess|htpasswd)$\”>
deny from all
</Files>

Redirect permanent /index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/event/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/menu/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/paticular/index.html http://gallery-saku.jp/close.html
Redirect permanent /cafe/recomendation/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/example/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/new/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/process/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/wind/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/taste/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/attraction/index.html http://gallery-saku.jp/close.html
Redirect permanent /gallery/product/light/index.html http://gallery-saku.jp/close.html
Redirect permanent /info/index.html http://gallery-saku.jp/close.html
Redirect permanent /inquiry/index.html http://gallery-saku.jp/close.html
Redirect permanent /nousaku/index.html http://gallery-saku.jp/close.html
Redirect permanent /plus1/index.html http://gallery-saku.jp/close.html
Redirect permanent /privacy/index.html http://gallery-saku.jp/close.html
order deny,allow