0
我得到了我的基本重定向工作与mod_rewrite
模块。当请求页面时localhost/home
它正确重定向到localhost/index.php?page=home
,但我遇到异常问题。添加例外mod_rewrite
我创建了一个文件夹api
其中我按类别存储文件,例如api/auth/register.php
和api/customer/create.php
。我试图使包含2个参数的重写规则(在本例中为验证码和客户),所以基本上它只是从网址中删除.php
。
,我所做的规则如下
RewriteRule ^api/(.*)/(.*)/?$ api/$1/$2.php [L]
增加该行对我的.htaccess后,问题开始出现。例如我的.css
和.js
文件开始重定向。所以也许我需要为apis做一些改动?你有其他想法来改进我的重写规则吗?
的.htaccess提前
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^api/(.*)/(.*)/?$ api/$1/$2.php [L] # problems started to occur after adding this line
RewriteRule (.*) index.php?page=$1 [L,QSA]
感谢。
它的工作正常。谢谢! – lingo