CentOS Stream 9
.htaccessを利用したく、/etc/httpd/conf/httpd.conf で /var/www/html/の「AllowOverride All」に設定しました。そして、/var/www/html/直下に .htaccessファイルを置き、httpdをrestartしました。
<Directory "/var/www/html"> Options FollowSymLinks AllowOverride All Require all granted </Directory>
/var/www/html/配下に置いたサイト(phpMyAdminへのログインページ)は.htaccessの設定が機能していることがわかりました。
私はmod_wsgiを利用してApacheとDjangoを連携させているのですが、ドキュメントルート配下以外にDjangoプロジェクトを置いた場合に.htaccessファイルの設定を機能させるにはどうすればよいでしょうか。/etc/httpd/conf/httpd.confの末尾には以下を追記しています。Django側では、http://[IPアドレス]/admin にアクセスしたときに、Django管理サイトを表示させていますが、.htaccessの設定を反映させたいです。
LoadModule wsgi_module /usr/local/anaconda3/lib/python3.9/site-packages/mod_wsgi/server/mod_wsgi-py39.cpython-39-x86_64-linux-gnu.so WSGIScriptAlias / /usr/local/django/backend/config/wsgi.py WSGIPythonHome /usr/local/anaconda3/ WSGIPythonPath /usr/local/django/backend <Directory /usr/local/django/backend/config> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static/ /usr/local/django/backend/static/ <Directory /usr/local/django/backend/static/> Require all granted </Directory>

回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。