使用 HT访问重定向问题


redirect issue using htaccess

我想使用 .htaccess abc.com/test.php重定向到 abc.com/test . 但它只会执行/显示测试的内容.php。

我应该怎么做?有什么建议吗?

试试看

RewriteRule ^test$ test.php [L]

[更新]

完整的重定向

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME}/ -d
RewriteCond %{SCRIPT_FILENAME}.php !-f
RewriteRule [^/]$ %{REQUEST_URI}/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^(.+)'.php$ /$1 [R=301,L]
RewriteCond %{SCRIPT_FILENAME}.php -f
RewriteRule [^/]$ %{REQUEST_URI}.php [QSA,L] 

这是使用重写规则而不是重定向完成的。像这样:

RewriteEngine On
RewriteRule ^/test.php$ /test [L,QSA]