Ubuntu 14.04でApache 2を実行しています。 rewrite_moduleが有効になります(sudo apachectl -M
)。 /etc/apache2/apache2.conf(httpd.confファイルのUbuntuのバージョン)でApache - httpd.confのmod_rewriteを使用して.phpと.htmlファイル拡張子を削除する
Iは、次のコードブロックを有する:
<Directory /var/www/>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond /%{REQUEST_FILENAME}.php -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.php
RewriteCond /%{REQUEST_FILENAME}.html -f
RewriteRule ^([a-zA-Z0-9_-\s]+)/$ /$1.html
</IfModule>
<IfModule mod_expires.c>
...
<IfModule mod_headers.c>
...
</IfModule>
</IfModule>
</Directory>
はsudo service apache2 restart
蘭。
私のサーバー上の.phpファイル拡張子なしのURLを訪問すると、404が表示されます。なぜこれは機能しないのですか?
申し訳ありませんが、それもうまくいきませんでした。 :( – torjinx