Vista マシンに Apache 2.2 を新規インストールしましたが、mod の書き換え以外はすべて正常に動作しています。
コメントを解除しました
LoadModule rewrite_module modules/mod_rewrite.s
しかし、私の書き換えルールはどれも機能しません。
RewriteRule not_found %{DOCUMENT_ROOT}/index.php?page=404
私が使用しているルールはすべてホスティング上で機能しているので、問題ないはずです。そこで質問なのですが、Apache 構成に mod 書き換えをブロックする可能性のある隠れた要素があるのでしょうか?
ベストアンサー1
使用するには、mod_rewrite
ターミナルで次のコマンドを入力します。
sudo a2enmod rewrite
apache2を再起動してください
sudo /etc/init.d/apache2 restart
または
sudo service apache2 restart
または新しい統一システム制御方法に従って
sudo systemctl restart apache2
その後、必要に応じて次の.htaccess
ファイルを使用できます。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
上記の.htaccess
ファイル ( に配置されている場合) は、ファイルが存在しない限り、内のDocumentRoot
すべてのトラフィックを 内のファイルにリダイレクトします。index.php
DocumentRoot
次のようなディレクトリ構造があり、httpdocsがDocumentRoot
httpdocs/
.htaccess
index.php
images/
hello.png
js/
jquery.js
css/
style.css
includes/
app/
app.php
httpdocs に存在するファイルは、.htaccess
上記の を使用して要求者に提供されますが、その他すべては にリダイレクトされますhttpdocs/index.php
。 のアプリケーション ファイルにはincludes/app
アクセスできません。