【发布时间】:2021-12-17 09:55:02
【问题描述】:
我有一个CodeIgniter项目,最近添加了一个Laravel Lumen API,所以文件夹结构如下
Project
- api/
- application/
- public/
- system/
- .htaccess
- index.php
在api/ 文件夹内是 Lumen 框架。在本地它运行良好,通过访问 url localhost/example.com/api/test 它返回 200 HTTP 代码。
.htaccesscodeigniter 根文件夹:
Options -Indexes
Options +FollowSymLinks
# Set the default file for indexes
DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [QSA,R,L]
RewriteCond $1 !^(index\.php|public|robots\.txt)
RewriteCond $1 !^([^\..]+\.php|robots\.txt|sitemap\.xml)
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 index.php
</IfModule>
.htaccesslumen api 文件夹:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
<Files .env>
Order allow,deny
Deny from all
</Files>
错误:
- 通过访问
example.com/api/test它返回 404 HTTP 代码codeigniter - 通过访问
example.com/api,它返回 404 HTTP 代码 按流明
【问题讨论】:
标签: .htaccess codeigniter lumen