ブログのレスポンシブ化により
携帯・スマホのURLを、PCと統一することになりました。
その際、旧URLを新URLに301リダイレクトするための
.htaccessの書き方で悩んでいます。
変更は下記のように、ドメイン直後にある
「/m」と「/mobile」だけを削りたいのですが、
正規表現の書き方がよくわかりません。
旧)http://example.com/m/半角英数ポスト名
新)http://example.com/半角英数ポスト名
旧)http://example.com/m/tag/半角英数タグ名
新)http://example.com/tag/半角英数タグ名
旧)http://example.com/m/category/半角英数カテゴリ名
新)http://example.com/category/半角英数カテゴリ名
旧)http://example.com/mobile/半角英数ポスト名
新)http://example.com/半角英数ポスト名
旧)http://example.com/mobile/tag/半角英数タグ名
新)http://example.com/tag/半角英数タグ名
旧)http://example.com/mobile/category/半角英数カテゴリ名
新)http://example.com/category/半角英数カテゴリ名
こちらで考えた301リダイレクトの記述
<IfModule mod_rewrite.c> RewriteEngine On RedirectMatch 301 ^/m/(\d+)$ http://example.com/$1 RedirectMatch 301 ^/m/([^/]+)/(\d+)$ http://example./$2 RedirectMatch 301 ^/mobile/(\d+)$ http://example.com/$1 RedirectMatch 301 ^/mobile/([^/]+)/(\d+)$ http://example./$2 </IfModule>1番目と2番目、および、3番目と4番目はまとめて記述でき、
リダイレクトは合計2行で表現できるのかと思いますが、
どのように記述したらよいかわかりません。
アドバイスを頂けないでしょうか。
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/01/11 00:32
2017/01/11 00:42
2017/01/14 11:15