首页 > 解决方案 > 如何编写具有两个入口点的简单 .htaccess

问题描述

我在尝试使用下面的 .htaccess 文件来指导我的请求时遇到问题。每一个都从 rest 到 rest.php 和其他到 index.php 开始。问题是所有请求都指向 index.php,即使是从休息开始的请求。我错过了什么 ?

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^rest(.+)$ rest.php? [QSA,L]
RewriteRule ^(.+)$ index.php? [QSA]

标签: php.htaccess

解决方案


下面的 .htaccess 似乎解决了我的问题,如果有错误,请在评论中写出来。

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^rest$ rest.php? [QSA,L]
RewriteRule ^rest(.+)$ rest.php? [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.+)$ index.php? [QSA]

推荐阅读