如何加载的php文件,而不php扩展 [英] How to load php file without php extension
问题描述
我有这方面的工作的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屋!