2
example.com/news.php
をexample.com/news
またはexample.com/news/
に書き換えようとしています。私のコードでexample.com/news
はうまく動作しますが、example.com/news/
は私に404が見つかりません。。拡張モジュールを削除するmod_rewriteが許容範囲外です
マイコード:
<Directory /var/www/>
Options -Indexes SymLinksIfOwnerMatch -MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule^%1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
RewriteRule ^games/csgo/([0-9]+)$ /games/csgo/view.php?id=$1 [L]
</IfModule>
</Directory>
私はexample.com/news
とexample.com/news/
へexample.com/news.php
をリダイレクトするにはどうすればよいですか?
'RewriteCond%{REQUEST_FILENAME}!-d'と' RewriteCond%{REQUEST_FILENAME} .php -f'を追加すると、それはサブディレクトリでも動作します。どうもありがとうございました! – Furentes
あなたはようこそ、私は答えを更新する –