开发者

Is it possible to handle such URL

http://www.example.com/http://www.test.com

I have tried many different methods using .htaccess with no luck. I need to get that second url coming as parameter. Is it possible to redirect it to index.php and get it as $_SERVER["REQUEST_URI"] or other method? Thanks

U开发者_如何学JAVAPD: Looks like it is impossible to get whole URL, question marks are not recognized. Ideal example:

127.0.0.1/http://www.test.com/script.php?a=hello&b=world#blabla;par2?%par3 

and i need to get in my index.php exact string

www.test.com/script.php?a=hello&b=world#blabla;par2?%par3


It's definitely possible: http://downforeveryoneorjustme.com/http://www.google.com/

As to how, it's been covered on ServerFault already


The Problem:

This is a problem with Apache running on Windows. Apache on Windows does not let you have a colon (:) in your REQUEST URI. This is basically for avoiding URLs like http://www.mysite.com/C:/SomeFile.exe but is actually annoying.

If you use mod_rewrite at the same time it will be skipped.

You and some applications (like wikipedia) uses colon : in URL. so what to do in Apache on Windows?

The Solution:

At the time of writing this answer this bug still persists and there is no absolute solution, BUT there is a trick:

You may change your URL to something like this: http://www.mysite.com/url/http://www.test.com

in this example http://www.mysite.com/ is your SCRIPT PATH and /url/http://www.test.com is your REQUEST URI.

The problem will be gone if there is a Slash (/) before Colon (:).


You can get the URI but only without the fragment since that is not transmitted to the server. Try this rule:

RewriteRule ^http:/ index.php [L]

Then the requested URI path plus query (so the part from the third / up to the first # or the end of the URI) is available at $_SERVER['REQUEST_URI'].

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜