1
我需要的,可以採取一個url像這樣的.htaccess文件:阿帕奇國防部,重寫的.htaccess段交換
http://example.com/api/module/something/something/something......
URL可以有段氮量和模塊是可變的,我需要什麼完成是改寫爲:
http://example.com/module/api/something/something/something......
目前這是與下面的PHP代碼來完成,但是這不是一個完美的解決方案
$pieces = explode("/", $_SERVER['REQUEST_URI']);
$pieces = array_slice($pieces, 2, count($pieces)-2,false);
$module = $pieces[0];
unset($pieces[0]);
$end = implode('/', $pieces);
header('Location: /'.$module.'/api/'.$end);
謝謝,請參閱我的編輯我忘了提及模塊是可變的。 – Stefan
@stefan我編輯了重寫規則 –
這並不完全是原創http://example.com/api/module/segment1/segment2 重寫 http://example.com/module/segment1/api/ segment2 – Stefan