こんにちは。サイトのhttps化で質問させて頂きます。
サイトをwww有りhttps有りにリダイレクトさせたい場合、
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] RewriteCond %{HTTP_HOST} !^www. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </IfModule>上記のようなソースになることは分かったのですが、更にURLの語尾に/mobile/をつけたい場合は、どう記述すればよろしいでしょうか?
http://example.com
↓
https://www.example.com/mobile/
いろいろと試したのですが分かりませんでした。
何卒よろしくお願いいたします。
気になる質問をクリップする
クリップした質問は、後からいつでもMYページで確認できます。
またクリップした質問に回答があった際、通知やメールを受け取ることができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
「mobile」のフォルダは存在するのですか?
2019/01/16 07:37
はい、存在します。
回答1件
0
ベストアンサー
更にURLの語尾に/mobile/をつけたい場合は、
URLの語尾じゃなくて、パスの先頭では?
Apache
1RewriteEngine On 2RewriteCond %{HTTPS} off 3RewriteCond %{REQUEST_URI} ^/mobile/ 4RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 5RewriteCond %{REQUEST_URI} !^/mobile/ 6RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
投稿2019/01/16 05:59
総合スコア84538
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/01/16 07:30
ありがとうございます。
教えて頂いた方法で
https://www.example.com/mobile/
に遷移することができました。
つきましては
https://www.example.com/mobile/index.html
に遷移する方法も教えて頂けないでしょうか。
何卒よろしくお願い致します。
2019/01/16 07:46
どこからそこへですか?
2019/01/17 06:06
http://example.com
からになります。
何卒よろしくお願い致します。
2019/01/17 06:53 編集
RewriteRule ^$ https://%{HTTP_HOST}/mobile/index.html [R=301,L]
このレベルが分からないというのはどういう事なんでしょうね?
> 上記のようなソースになることは分かったのですが、
本当に分かってますか?
2019/01/17 07:40
すみません、index.htmlを付け加えればよいだけだったのですね。失礼しました。
とりあえず以下のコードを置いたのですが、
ブラウザ上に「リダイレクトが繰り返し行われました」とエラーが出ました。
何が間違っているかご教授願えませんでしょうか。
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType image/x-icon "access 1 week"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
# iPod
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/mobile/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
# iPhone
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/mobile/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
# iPad
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/mobile/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
# Android
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/mobile/
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
</IfModule>
2019/01/17 11:28
色々とすみません。
以下のコードで解決しました。
ご教授頂きまして、ありがとうございました。
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType image/x-icon "access 1 week"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} (iPod|iPhone|iPad|Android|Windows\ Phone)
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/mobile/
RewriteRule .* https://%{HTTP_HOST}/mobile%{REQUEST_URI} [L,R=301]
</IfModule>
あなたの回答
tips
太字
斜体
打ち消し線
見出し
引用テキストの挿入
コードの挿入
リンクの挿入
リストの挿入
番号リストの挿入
表の挿入
水平線の挿入
プレビュー
質問の解決につながる回答をしましょう。 サンプルコードなど、より具体的な説明があると質問者の理解の助けになります。 また、読む側のことを考えた、分かりやすい文章を心がけましょう。