passing a URL to a php page

I am trying to pass an encoded URL to a php page like so:

http://mywebsite.com/_links/add-link.php?u=http%3A%2F%2Fanotherwebsite.com%2Fpage.html&t=page%title

This link works on a one webserver but not another (the one on which I need to use the code).

On the first webserver the URL and page title are displayed perfectly, but on the second one I get the “page not found” error.

If I remove the ‘colon’ in ‘http:’ it works. If I remove the double slashes in ‘http://’ it works.

It must be a php setting? But which one?

Thanks for any help.

on the webserver that id does not work is there a .htaccess file?
can you use the url’s without http:// on both servers? if so why not just do that? is add-link.php exactly the same on both servers?
and lastly what version of php are you using on both servers?

Yes, there is a .htaccess file on the server that won’t handle the link correctly.

I don’t know how I can use the URLs without the “http://” because the link (http://mywebsite.com/_links/add-link.php?u=http%3A%2F%2Fanotherwebsite.com%2Fpage.html&t=page%title) is being created by javascript using this code:

javascript:location.href='http://americanvalues.org/_links/frame/add-link.php?u=’+encodeURIComponent(location.href)+’&t=’+encodeURIComponent(document.title);

(I am tring to make a bookmarklet that adds newlinks to a database.)

add-link.php is the same on both servers; and both servers are running 5.2.16 and 5.2.17.

register_globals is “off” on the server that works and “on” on the server that doesn’t work.

Thanks!

well first thing you should do is turn register globals off for security reasons. next can I see the .htaccess file so I can see what is written that we can alter to make fit for you.

the contents of the htaccess file are:


AddHandler application/x-httpd-php5 .php .xml

DirectoryIndex index.html index.php

ErrorDocument 404 /notfound.php
ErrorDocument 403 /notfound.php


If I remove the custom error page lines from the htaccess file, the error reads:

Forbidden
You don’t have permission to access /_links/frame/add-link.php on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I have found the javascript code to remove the colon from the URL and now I can get the variable passed with the URL to echo back on the php page:

encodeURIComponent(document.title).replace(/:/g, ‘’);

well good news sorry I could not help you out there!! But I am glad you got it figured out! :wink:

Thanks for your help. I didn’t really figure it out; just found a work around. I don’t know what it is about the web server set up that would make it impossible to pass viariable through the URL…

Sponsor our Newsletter | Privacy Policy | Terms of Service