mod_rewrite
が有効な場合にのみ処理をする。
<IfModule mod_rewrite.c>
RewriteEngine on
# 処理
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
301リダイレクトの記述
Redirect permanent /sample/ http://wwww.example.com/index.php
302リダイレクトの記述
Redirect 302 /sample/ http://wwww.example.com/index.php
301リダイレクトの記述
RedirectMatch permanent ^/index\.html$ https://example.com/example/
302リダイレクトの記述
RedirectMatch 302 ^/index\.html$ https://example.com/example/