MENU

移転のリダイレクトについて

例えばサーバー移転やドメイン変更などを行う場合に使えるコード。

跡地へのアクセスすべてを「https://exmaple.net/index.html」に転送かける方法。
以下のコードを「.htaccess」に記載します。

RewriteEngine On

RewriteBase /

RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !^.*\.(gif|jpg|jpeg|png|swf|css|js)$ [NC]
RewriteRule ^(.*)$ https://exmaple.net/index.html [L,R]

RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ https://exmaple.net/index.html [L,R]

「.htaccess」を置いたサーバーのURLにアクセスした場合、すべてのページを「https://exmaple.net/index.html」に転送させることができます。

目次