HTTP -> HTTPS로 할 경우
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</ifModule>
모바일 사이트와 데스크톱 사이트의 전환
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/mobile/
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|Android.*Mobile|Windows.\ Phone)
RewriteRule ^(.*)$ mobile/$1 [R]
RewriteCond %{REQUEST_URI} /mobile/
RewriteCond %{HTTP_USER_AGENT} !(iPod|iPhone|Android.*Mobile|Windows.\ Phone)
RewriteRule ^mobile/(.*)$ $1 [R]
</ifModule>
www.helloworld.com에 접속해도
helloworld.com으로 접속하도록 유도
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.helloworld\.com$
RewriteRule ^(.*)$ https://helloworld.com/$1 [R=301,L]
</ifModule>
helloworld.com에 접속해도
www.helloworld.com으로 접속하도록 유도
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^helloworld\.com$
RewriteRule ^(.*)$ https://www.helloworld.com/$1 [R=301,L]
</ifModule>
하부 URL경로가 바뀌었을 경우
helloworld.com/hello -> helloworld.com/world
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^hello(.*)$ /world$1 [R=301,L]
</ifModule>
URL을 완전히 바꾸었을 때
https://helloworld.com/newbie/newbie.html 로 접속했을 때
https://new-helloworld.com/begineer/start.html 로 리다이렉트 시켜줌
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteRule https://helloworld.com/newbie/newbie.html https://new-helloworld.com/begineer/start.html [R=301,L]
</ifModule>
HTTP -> HTTPS로 할 경우
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</ifModule>
모바일 사이트와 데스크톱 사이트의 전환
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !/mobile/
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|Android.*Mobile|Windows.\ Phone)
RewriteRule ^(.*)$ mobile/$1 [R]
RewriteCond %{REQUEST_URI} /mobile/
RewriteCond %{HTTP_USER_AGENT} !(iPod|iPhone|Android.*Mobile|Windows.\ Phone)
RewriteRule ^mobile/(.*)$ $1 [R]
</ifModule>
www.helloworld.com에 접속해도
helloworld.com으로 접속하도록 유도
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.helloworld\.com$
RewriteRule ^(.*)$ https://helloworld.com/$1 [R=301,L]
</ifModule>
helloworld.com에 접속해도
www.helloworld.com으로 접속하도록 유도
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^helloworld\.com$
RewriteRule ^(.*)$ https://www.helloworld.com/$1 [R=301,L]
</ifModule>
하부 URL경로가 바뀌었을 경우
helloworld.com/hello -> helloworld.com/world
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^hello(.*)$ /world$1 [R=301,L]
</ifModule>
URL을 완전히 바꾸었을 때
https://helloworld.com/newbie/newbie.html 로 접속했을 때
https://new-helloworld.com/begineer/start.html 로 리다이렉트 시켜줌
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteRule https://helloworld.com/newbie/newbie.html https://new-helloworld.com/begineer/start.html [R=301,L]
</ifModule>
많이들 쓰는 방법은 요정도?
정리가 필요하면 하나씩 더 추가..