問題描述
使用新的 Diggbar,您可以將 http://digg.com
放在您當前所在的任何 URL 前面,它會創(chuàng)建一個 Digg 短 URL.我只是假設(shè)他們通過 modrewrite 來做到這一點(盡管我不確定,因為我是新手).
With the new Diggbar, you can put http://digg.com
in front of any URL that you are currently at and it will create a Digg short URL. I am only assuming they do this by modrewrite (though I am not sure since I am new at this all).
這是怎么做到的?在我看來,當我在我正在開發(fā)的網(wǎng)站上嘗試此操作時,它會爆炸.
How is this done? It seems to me when I try this with a website I am working on, it bombs out.
我希望能夠做到以下幾點:
I want to be able to do the following:
http://example.com/http://stackoverflow.com/question/ask
并有一個 modrewrite 將允許這個去
and have a modrewrite that will allow this to go to
http://example.com/index.php?url=http://stackoverflow.com/question/ask
但是當我使用這個 modrewrite 時:
But when I use this modrewrite:
RewriteEngine on
RewriteRule ^([A-Za-z0-9]+)$ /message.php?id=$1 [L]
它不起作用.我做錯了什么?
it doesn't work. What am I doing wrong?
推薦答案
您必須從 請求行 因為 Apache 刪除了空路徑段.最初請求的 URI 路徑 /http://foobar/
變?yōu)?/http:/foobar/
.但請求行 (THE_REQUEST
) 保持不變:
You have to take the value from the request line because Apache removes empty path segments. The initially requested URI path /http://foobar/
becomes /http:/foobar/
. But the request line (THE_REQUEST
) stays untouched:
RewriteCond %{THE_REQUEST} ^GET /(https?://[^s]+)
RewriteRule ^https?:/ index.php?url=%1 [L]
這篇關(guān)于Diggbar modrewrite - 他們?nèi)绾瓮ㄟ^ modrewrite 傳遞 URL?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!