わかりました、私は何時間もそれと戦ってきました。必要なことを行う 3 つの異なる .htaccess スクリプトがありますが、それらを混在させることはできません。
(example.com/gallery.php -> example.com/gallery) からきれいな URL を作成します。
Options +FollowSymLinks RewriteEngine On RewriteRule ^([a-zA-Z0-9]+)$ $1.php
#1 のスクリプトは example.com/index.php を example.com/index に転送するため、このコードは index.php を削除するので、example.com/index.php -> example.com
Options +FollowSymLinks -MultiViews # Turn mod_rewrite on RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?$1 [L,QSA] RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s(.*)/index\.php [NC] RewriteRule ^ /%1 [R=301,L]
スクリプトは末尾にスラッシュを追加する必要があるため、example.com/gallery -> example.com/gallery/
# invoke rewrite engine RewriteEngine On RewriteBase /~new/ # add trailing slash if missing rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]
これらの 3 つのスクリプトを 1 つのユニバーサル URL スクリプトに結合するのを手伝ってくれる人はいますか