htaccess ファイルに次のコードがあります。
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
#vanity URL
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([a-zA-Z0-9-_]*)$ /profile.php?username=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \ /profile\.php\?username=([^&\ ]+)&?([^\ ]*)
RewriteRule ^ /%1?%2 [L,R=301]
#remove file extensions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
ErrorDocument 400 /404.php
ErrorDocument 401 /404.php
ErrorDocument 403 /404.php
ErrorDocument 404 /404.php
ErrorDocument 500 /404.php
<Files .htaccess>
order allow,deny
deny from all
</Files>
バニティ URL に関しては問題なく動作しますが、URL の末尾にあるphp 拡張子を削除するとうまくいきません:
1.と入力するmysite.com/home.php
と にリダイレクトされますhome.php
が、拡張機能はアドレス バーに表示されたままです。
2.を入力mysite.com/home
すると、カスタム エラー ページにリダイレクトされhome
ます。ユーザー名がデータベースではないためです。
1. と 2. を修正するにはどうすればよいですか?