用的.htaccess隐藏PHP扩展重写URL [英] Rewrite URL with .htaccess to hide PHP extension

查看:299
本文介绍了用的.htaccess隐藏PHP扩展重写URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,我正在开发一个Web服务为特定的应用程序。 上周,我转我的备份在Server1到Server2,因为那一刻我的.htaccess将无法正常工作了。

I've a question, I'm developing a webservice for a specific app. Last week I transferred my back-up from server1 to server2, since that moment my .htaccess won't work anymore.

网址为我的web服务是: http://apps.holtesdesign.nl/inholland/apiv0/

The url for my webservice is: http://apps.holtesdesign.nl/inholland/apiv0/

这个URL工作正常,加载错误报告模块: http://apps.holtesdesign.nl/inholland/apiv0/bugreport.php

This url works fine, to load the bugreport module: http://apps.holtesdesign.nl/inholland/apiv0/bugreport.php

但是URL应该是: http://apps.holtesdesign.nl/inholland/apiv0/bugreport

But the url was supposed to be: http://apps.holtesdesign.nl/inholland/apiv0/bugreport

当你打开最后浏览的网址,你会发现它会导致内部服务器错误。 你知道它是如何可能的?

When you'll open the last url, you'll see that it will result in an internal server error. Do you know how it's possible?

我的.htaccess是这样的:

My .htaccess looks like:

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

服务器上运行CentOS的,如果mod_rewrite并运行我已经检查...

The server is running on CentOS, and I've already checked if mod_rewrite is functioning...

我希望你能帮助我的人!

I hope you can help me guys!

干杯,

Jelmer

推荐答案

这将解决这个问题:

RewriteEngine On

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

这篇关于用的.htaccess隐藏PHP扩展重写URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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