1
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.

mod_rewrite(.htaccess)記載例

Posted at

サブドメイン毎にhttpsでリダイレクト

# not https start
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^domain\.jp$
RewriteRule ^(.*)$ https://domain.jp/$1 [R=301,L]
	
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^sub\.domain\.jp$ [NC]
RewriteRule ^(.*)$ https://sub.domain.jp/$1 [R=301,L]	
# not https end

特定のディレクトリのみリダイレクト

(開発段階では302リダイレクトにするのがみそ、
301にして間違っていたらブラウザキャッシュクリアするのが面倒)

RewriteEngine on
RewriteBase /
RewriteRule ^directory(.*)$ https://domain.jp/directory/ [R=302,L]
1
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
1
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?