tags:

views:

47

answers:

2

http://www.mysite.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

UPD: 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

+2  A: 

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

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

Michael Mrozek
Try option 2 but change the last line to`RewriteRule ^/(.*) /index.php?url=$1`Everything that isn't index.php will redirect to index.php passing the URL specified as a get argument 'url'.
Matt S
the 1st solution (on ServerFault) doesn't work perfectly: $1 cannot handle "?" symbol. That means if my .htaccess is RedirectMatch permanent ^/(?<!index\.php)(.*) http://example.com/index.php?url=$1and I will request www.mysite.com/http://www.test.com/?par=1 -- it cuts "?par=1" and result will be http://www.test.com/
Vitaly
A: 

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'].

Gumbo
anyway i'm getting 403 (Access forbidden) error, that's because of colons (:) in the URL. I try 127.0.0.1/http://www.test.com
Vitaly
@Vitaly: And what does the server’s error and access log say?
Gumbo
error_log says "[Thu May 27 22:01:08 2010] [error] [client ::1] (20024)The given path is misformatted or contained invalid characters: Cannot map GET /http://hjh HTTP/1.1 to file"access_log says "127.0.0.1 - - [27/May/2010:21:03:17 +0300] "GET /http://hjh HTTP/1.1" 403 1175 "-" "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.55 Safari/533.4"
Vitaly
@Vitaly: This seems to be a known issue with Windows systems (see https://issues.apache.org/bugzilla/show_bug.cgi?id=41441).
Gumbo