mod_rewrite

画像等はそのまま

RewriteEngine On RewriteRule ^(.*\.(png|gif|jp?g|js|css))$ $1 [NC,L]

特定のurlだけhttpsアクセス

//example.com/hoge/ と //example.com/moge/ は https RewriteEngine On RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI} !(^/(hoge|moge)/) RewriteRule ^(.*) http://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{HTTPS} on RewriteCond %{REQUEST_URI}…

.htaccessで相対パス対応

例えば ../img/foobar/hoge.png を img/foobar/hoge.png にしたい 画像は、webroot/img/の中に全て入ってるという条件 RewriteRule ^.*\/((img|js|css)\/.*\.(png|gif|jp?g|js|css))$ $1 [NC,L]