4
3

More than 5 years have passed since last update.

さくらサーバーでRewriteが動かない問題

Last updated at Posted at 2016-05-08

http://path/gallery.php
http://path/gallery で表示したい。

ローカルでは動くのに、さくらのサーバーに上げた時だけ.htaccessが動かなかったので MultiviewsMatch Any を追加した。

それを含めて以下のような.htaccessを作成

# さくらサーバー専用の対策
MultiviewsMatch Any
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

参考
さくらサーバーのマルチドメイン環境下でmodRewriteが動かない場合の原因と対処法


今回は必要なかったRewriteBase /
http://q.hatena.ne.jp/1165927535

RewriteCond %{REQUEST_FILENAME} !-d の意味は
フォルダ(-d)がある場合は、直後の処理のリライトルールを適用しない
http://nandani.sakura.ne.jp/web_all/server/15/

RewriteCond は、RewriteRule を実行するための条件を定義
http://weblabo.oscasierra.net/apache-rewritecond-base/
http://web.tvbok.com/web/server/rewritecond_rewriterule.html

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3