1

私はいくつかのhtmlファイルを含むサイトを持っています。それらの 1 つが contact.html です。これは私の .htaccess です。site.com/contact でページをアドレス指定できますが、site.com/contact/ ではアドレス指定できないという問題があります。(末尾のスラッシュに注意してください。) 修正方法は?

RewriteEngine On

# If the requested URI does not contain a period in the final path-part
RewriteCond %{REQUEST_URI} !(\.[^./]+)$
# and if it does not exist as a directory
RewriteCond %{REQUEST_fileNAME} !-d
# and if it does not exist as a file
RewriteCond %{REQUEST_fileNAME} !-f
# then add .html to get the actual filename
rewriterule (.*) /$1.html [L]
4

2 に答える 2

1

それ以外の:

rewriterule (.*) /$1.html [L]

試す:

RewriteRule ^([^/]*)/?$ /$1.html [L]
于 2009-05-21T21:23:23.343 に答える
0
RewriteRule ^([^/]*)/?$ $1.php [L]

私の場合、 $1 の前のスラッシュを削除すると、うまくいきます! あなたのコメントから多くのことを学ぶことができて感謝しています。

于 2012-02-26T15:44:11.760 に答える