如何重定向localhost/test/test.php到重定向localhost/test/test


How to redirect localhost/test/test.php to redirect localhost/test/test

这是我的。htaccess代码

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On**RewriteBase /RewriteRule ^test/?$ test.php [L,NC]

但它没有将我重定向到"test"。是否有任何错误在。htacces或我必须做一些Apache配置更改。由于

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
## hide .php extension
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}'s([^.]+)'.php [NC]
RewriteRule ^ %1 [R,L,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [L]

试试这个

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}'.php -f
RewriteRule ^(.*)$ $1.php