简体   繁体   English

SLIM Framework中的配置.htaccess

[英]Configuration .htaccess in SLIM Framework

How do I adjust the .htaccess file for my slim-framework? 如何为超薄框架调整.htaccess文件?

I have this folders/files: 我有以下文件夹/文件:

  • /src/slim.php
  • /public/.htaccess

My URL points to the "public" directory. 我的URL指向“公共”目录。 And I want to create a virtual "folder" so if I call http://example.com/api/... it should open my slim application in the src folder. 而且我想创建一个虚拟的“文件夹”,因此,如果我调用http://example.com/api/...它将在src文件夹中打开我的苗条应用程序。

I have created this .htaccess file, but it doesn't work. 我已经创建了这个.htaccess文件,但是它不起作用。

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^api ../src/slim.php

This error message appears: 出现此错误消息: 错误消息苗条框架

My URL points to the "public" directory. 我的URL指向“公共”目录。
:
The document root is "htdocs/project/src". 文档根目录为“ htdocs / project / src”。

It's not clear how your "URL points to the public directory", when your document root appears to point elsewhere? 当文档根目录似乎指向其他位置时,不清楚您的“ URL指向public目录”如何? Do you have another .htaccess file in the document root perhaps? 您在文档根目录中是否还有另一个.htaccess文件?

Anyway, it looks like you might be trying to rewrite to a file that is outside the document root? 无论如何,看来您可能正在尝试重写文档根目录之外的文件? That is not possible using mod_rewrite in a .htaccess context. .htaccess上下文中使用mod_rewrite是不可能的。 The server will likely respond with a 400 Bad Request . 服务器可能会响应400 Bad Request

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM