我如何删除“的.php”扩展名的网址? [英] How do I remove the '.php' extension from URLs?

查看:134
本文介绍了我如何删除“的.php”扩展名的网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是那里的PHP文件是:

ts1.WEBSITENAMEHERE.biz/cp /

.htaccess文件也是这个文件夹中。 我想删除从FILENAME.PHP的.PHP。

这是我目前的'的.htaccess文件:

 选项+了FollowSymLinks
RewriteEngine叙述上
的RewriteBase / CP
重写规则^(。*)/ $ $ 1.PHP
 

但它不工作。这是为什么?

解决方案

  RewriteEngine叙述上
的RewriteBase / CP /

的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!\ PHP $
重写规则。* $ 0.php [L]
 

This is where the PHP files are:

ts1.WEBSITENAMEHERE.biz/cp/

The .htaccess file is also in this folder. I want to remove the '.php' from 'FILENAME.PHP'.

This is my current '.htaccess' file:

Options +FollowSymlinks
RewriteEngine on 
RewriteBase /cp
RewriteRule ^(.*)/$ $1.php

But it is not working. Why is this?

解决方案

RewriteEngine on
RewriteBase /cp/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !\.php$
RewriteRule .* $0.php [L]

这篇关于我如何删除“的.php”扩展名的网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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