如何加载的php文件,而不php扩展 [英] How to load php file without php extension

查看:118
本文介绍了如何加载的php文件,而不php扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这方面的工作的htaccess

I have this working htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^test/([0-9]+)/?$ test.php?id=$1 [L]

我的问题了,如果我有我的htaccess的规则,我怎么可以加载没有扩展名为.php的PHP文件。

my question for this if I have that rule on my htaccess how can I load php file that have no .php extension.

我将它添加到我的htacess

I add this to my htacess

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

它正常工作的http://本地主机/ myProjectFolder的/帐户 但是这不会工作了的http://本地主机/ myProjectFolder的/ 1 我怎样才能让他们俩的工作?

It works fine http://localhost/myprojectfolder/account but this will not work anymore http://localhost/myprojectfolder/1 how can I make them both working ?

感谢你在前进。

推荐答案

如果您在使用本网址的http://本地主机/ myProjectFolder的/ 1 在您的其他问题。然后测试甚至不应该在第一个规则。然后,你可以确保该文件存在。

If you are using this URL http://localhost/myprojectfolder/1 as in your other question. Then test shouldn't even be in the first rule. Then you can just make sure the file exists.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/?$ test.php?id=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

这篇关于如何加载的php文件,而不php扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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