質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.49%
.htaccess

Apacheウェブサーバーにおいて、ディレクトリ単位で設置及び設定を行う設定ファイルを指します。

Q&A

解決済

1回答

301閲覧

リダイレクト設定すると絶対パスが表示されてしまいます。

QOOSO_PLAN

総合スコア12

.htaccess

Apacheウェブサーバーにおいて、ディレクトリ単位で設置及び設定を行う設定ファイルを指します。

0グッド

0クリップ

投稿2018/06/29 07:09

URL間違いに伴い、下記のように301リダイレクトを設置しました。
しかし、リダイレクト先が絶対パスになってしまいうまくアクセスできません。

#コードの記述

RewriteEngine On RewriteRule ^gallery/design/bellipaint-design-([0-9]{3})/$ gallery/design/bellypaint-design-$1/ [R=301,L]

#リダイレクトされた結果
https://www.heartkoru.com/home/heartkoru/heartkoru.com/public_html/gallery/design/bellypaint-design-001/

本来は下記のようにならなければなりません。
https://www.heartkoru.com/gallery/design/bellypaint-design-001/

解決方法をご存知の方がいらっしゃいましたら、ご教授いただけますと大変助かります。

なお、全記述は下記の通りです。


Options +FollowSymLinks AddDefaultCharset utf-8 #www有りに正規化 RewriteEngine on RewriteCond %{HTTP_HOST} ^(heartkoru.com)(:80)? [NC] RewriteRule ^(.*) https://www.heartkoru.com/$1 [R=301,L] #index.htmlなしに正規化 RewriteEngine on RewriteCond %{THE_REQUEST} ^.*/index.html RewriteRule ^(.*)index.html$ https://www.heartkoru.com/$1 [R=301,L] #SSLリダイレクト RewriteEngine on RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] #404ページへの誘導 ErrorDocument 404 /404.html RewriteEngine On RewriteCond %{QUERY_STRING} lightbox= RewriteRule ^/gallery/? [R=301,L] RewriteEngine On RewriteRule ^gallery/design/bellipaint-design-([0-9]{3})/$ gallery/design/bellypaint-design-$1/ [R=301,L] #ページ単位の301 Redirect permanent /princess https://www.heartkoru.com/bellypaint-menu/princess/ Redirect permanent /babyphoto-1 https://www.heartkoru.com/mother/baby-photo/ Redirect permanent /maternitypaint-design?lightbox=image_1ssd https://www.heartkoru.com/gallery/ Redirect permanent /maternity-photo https://www.heartkoru.com/bellypaint-menu/maternity-photo/ Redirect permanent /bellypaint https://www.heartkoru.com/bellypaint-menu/ Redirect permanent /maternitypaint-design https://www.heartkoru.com/gallery/ Redirect permanent /aboutus https://www.heartkoru.com/about/ Redirect permanent /babyphoto https://www.heartkoru.com/mother/breastfeeding/ Redirect permanent /bellypaint-memo https://www.heartkoru.com/about/ Redirect permanent /blank https://www.heartkoru.com/copyright/ Redirect permanent /blank-1 https://www.heartkoru.com/gift/ Redirect permanent /maori https://www.heartkoru.com/bellypaint-menu/maori/ Redirect permanent /staff https://www.heartkoru.com/about/ Redirect permanent /menu3 https://www.heartkoru.com/faq/ Redirect permanent /menu1 https://www.heartkoru.com/about/ Redirect permanent /company https://www.heartkoru.com/about/ Redirect permanent /staff-1 https://www.heartkoru.com/about/ Redirect permanent /maternitypaint-design https://www.heartkoru.com/gallery/ Redirect permanent /petit-flower https://www.heartkoru.com/bellypaint-menu/petit-flower/ Redirect permanent /originalgoods https://www.heartkoru.com/gift/ Redirect permanent /trial https://www.heartkoru.com/bellypaint-menu/trial/ Redirect permanent /decoart https://www.heartkoru.com/bellypaint-menu/ Redirect permanent /#!bellypaint-menu/ https://www.heartkoru.com/bellypaint-menu/ Redirect permanent /gallery/?lightbox=dataItem-j2qspwgr https://www.heartkoru.com/gallery/ Redirect permanent /gallery/?lightbox=dataItem-it14z4i8 https://www.heartkoru.com/gallery/ #gzip圧縮 <IfModule mod_deflate.c> SetOutputFilter DEFLATE BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.0[678] no-gzip BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|ico)$ no-gzip dont-vary SetEnvIfNoCase Request_URI _.utxt$ no-gzip #DeflateCompressionLevel 4 AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/atom_xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript AddOutputFilterByType DEFLATE application/x-httpd-php AddOutputFilterByType DEFLATE application/x-font AddOutputFilterByType DEFLATE application/x-font-opentype AddOutputFilterByType DEFLATE application/x-font-otf AddOutputFilterByType DEFLATE application/x-font-truetype AddOutputFilterByType DEFLATE application/x-font-ttf </IfModule> SetEnvIf Request_URI ".*" AllowCountry

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

RewriteBase /
の設定方法が間違っていたことがわかりました。

閲覧いただいた方々ありがとうございました。

#www有りに正規化 RewriteEngine on RewriteBase / <- 追加

投稿2018/06/30 02:29

QOOSO_PLAN

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.49%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問