0

PHP Web サイトを作成しました。ここでは、クリーン URL を .htaccess ファイルに実装しました。へのmuリンクを表示する必要があり mydomain/index.phpますmydomain/index

だから私は使用しました

RewriteRule index index.php

しかし、私はたくさんのファイルを持っています。では、このページ全体に共通のルールをどのように記述すればよいでしょうか?

例えば

RewriteRule hotels hotels.php

ありがとう

4

1 に答える 1

1

これを試して:

#Setup
Options +FollowSymLinks
RewriteEngine On

#Remove trailing slashes
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ /$1 [R=permanent,QSA]

#Your thing
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ $1.php [L,QSA]
于 2012-04-18T11:04:56.147 に答える