重定向的.php没有.PHP [英] Redirect .php to no .php

查看:182
本文介绍了重定向的.php没有.PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在我的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

这篇关于重定向的.php没有.PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆