我需要在/ test/v1 /文件夾中將localhost/test/v1/rates等所有url重定向到api.php,並在/ test/v1 /文件夾中調用localhost/test/v2/rates給api.php。 v2 /文件夾(MAMP服務器)本地主機上的htaccess mod_rewrite
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /test/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./v1/(.*)$ /test/v1/api.php?request=$1 [QSA,NC,L]
</IfModule>
之前的代碼不起作用。我剛剛用盡了幾乎所有的可能性。
請寄給我正確的方向。
記住RewriteRule'的'第一個參數是一個正則表達式。 '。/ something'作爲正則表達式沒有任何意義。找出你正在匹配的是什麼。在'.htaccess'上下文中,'.htaccess'文件所在的文件夾將從您匹配的url中刪除。該網址永遠不會以'/'開頭。 – Sumurai8