2
我有這樣一個URL:Apache的mod_rewrite的雙斜線轉換成一個斜槓
http://example.com/img.php?url=http://example2.com/path/to/image/name.jpg
,所以我被這個問題的幫助下創建的規則Apache mod_rewrite complex URL regex
RewriteRule ^img.php\/(.+?(?:\.jpg|\.png))$ img.php?url=$1
但是當我使用這個規則htaccess文件並使用相同的URL,如下所示:
http://example.com/img.php/http://example2.com/path/to/image/name.jpg
結果雙斜槓後在我的參數http:轉換爲一個斜線!所以我的第一個參數在PHP變成:
http:/example2.com/path/to/image/name.jpg
你能幫我嗎?
謝謝@anubhava但是當我使用這個規則時,php中的url參數是空的!爲什麼? – 2015-01-21 07:41:33
對不起,我的錯誤。它應該是'%1'而不是'$ 1'。立即嘗試更新的代碼。 – anubhava 2015-01-21 07:46:44
非常感謝你,你的代碼像一個冠軍:) – 2015-01-21 07:59:46