windows10のWSLでApache2のmod_rewriteを有効にするやり方
windows10のWSL Apache2のmod_rewriteを有効にするやり方
.htaccessを設定してもURLの書き換えが出来ない場合モッズリライトが有効になっていない可能性があります(2018/05/24時点では有効ではありませんでした)
mod_rewrite.soモジュールが有効か確認
$ apache2ctl -M
コンパイル時に読み込まれたモジュールは (static)と表示され
apache実行時に読み込んだもの(DSO:Dynamic Shared Object)は(shared)と表示されます
有効ではないですね
Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) php7_module (shared) setenvif_module (shared) status_module (shared)
a2enmodコマンドを使ってmod_rewrite.soモジュールを有効化します
$ sudo /usr/sbin/a2enmod rewrite
a2enmodはモジュールを有効化、逆にa2dismodで無効化します
apache2の設定ファイルを修正してhtaccessを有効にします
$ sudo vi /etc/apache2/apache2.conf
<Directory /var/www/> Options Indexes FollowSymLinks #AllowOverride None AllowOverride All Require all granted </Directory>
apacheの再起動
$ sudo service apache2 restart