前提・実現したいこと
■ディレクトリ構成
documentroot/
├ subdir/
│ └ index.html
├ a.html
├ b.html
├ c.html
├.htaccess
└ index.html
■URL(ドキュメントルート)
http://example.co.jp
■実現したいこと
どのようなリクエストがきても全てドキュメントルート直下のindex.htmlにリライトしたい
(例えばhttp://example.co.jp/foo.htmlとURL入力するとhttp://example.co.jp/index.htmlにする)
発生している問題
http://example.co.jp/subdirとアドレスバーに入力してエンターすると
http://example.co.jp/index.htmlではなくhttp://example.co.jp/subdir/index.htmlにアクセスされる。
(http://example.co.jp/a, http://example.co.jp/b, http://example.co.jp/c, 等を入力した場合は
正しくhttp://example.co.jp/index.htmlにアクセスされる。サブディレクトリ名をURLに指定した場合だけうまくいかない。)
.htaccessの設定
RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.html [L]
質問内容
前提、実現したいことのとおりなのですが、
どのように.htaccessを書き換えればよいか教えていただきたいです。
回答2件
あなたの回答
tips
プレビュー