重定向的.php没有.PHP重定向、php、PHP

2023-09-02 11:41:09 作者:画窗。

我已经在我的htaccess的文件

I have this in my htaccess file

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

这将让人们访问服务器/ login.php中刚才服务器/登录但我怎样才能使就这样,如果服务器/ login.php中输入到地址栏会重定向到服务器/登录

Which will allow people to access server/login.php as just server/login but how can I make it so that if server/login.php is entered into the address bar it will redirect to server/login.

我的网站获得不同的点击率,而不是因为这个问题只是一个网址,感谢您的精力和时间。

My site is getting different hits rather than just for one url because of this issue, thanks for your effort and time.

推荐答案

更​​改您的基本路径的RewriteBase /路径/

Change your base path RewriteBase /path/

RewriteEngine on
RewriteBase /path/

RewriteCond %{THE_REQUEST} .php
RewriteRule ^(.*).php$ $1 [R=301,L]

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