如何用两个入口点编写一个简单的.htaccess文件

时间:2018-07-23 07:50:04

标签: php .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]

1 个答案:

答案 0 :(得分:-1)

.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]