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