在URL省略index.php文件时,一定要得到404错误的超薄框架 [英] Always get 404 error in Slim Framework when omitting index.php in URL
问题描述
我创建了一个测试的Hello World应用修身以下说明这里。
当我拨打这个电话,我得到一个404错误:
的http:// my_server的/ my_app应用/你好/约翰·
在另一方面,当我提出这个称之为盛大的作品,因为我得到一个你好约翰消息:
HTTP://my_server/my_app/index.php/hello/John
但是,当然,我不希望在的index.php我的网址...什么可能是错的?
======= =======编辑
我忘了创建这样的.htaccess文件(以下超薄框架文件,并在同一目录下的index.php):
RewriteEngine叙述在
的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^的index.php [QSA,L]
现在我得到这个错误:
/physical_path_to_my_files/index.php在此服务器上找到
如果您的htaccess文件是在你的 / my_app应用
目录,改变你的规则:
RewriteEngine叙述在的RewriteBase / my_app应用/的RewriteCond%{} REQUEST_FILENAME!-f
重写规则^的index.php [QSA,L]
如果它在你的文档根目录下,你需要添加路径:
重写规则^ /my_app/index.php [QSA,L]
I created a test hello world Slim app following instructions here.
When I make this call I get a 404 error:
http://my_server/my_app/hello/John
In the other hand, when I make this call it works grand as I get a "Hello John" message:
http://my_server/my_app/index.php/hello/John
But, of course, I don't want index.php in my URLs... What can be wrong?
======= EDIT =======
I forgot creating .htaccess file like this (following Slim Framework documentation, and in same directory as index.php):
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
Now I get this error:
/physical_path_to_my_files/index.php was not found on this server
If your htaccess file is in your /my_app
directory, change your rules to:
RewriteEngine On
RewriteBase /my_app/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
If it's in your document root, you need to append the path:
RewriteRule ^ /my_app/index.php [QSA,L]
这篇关于在URL省略index.php文件时,一定要得到404错误的超薄框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!