Jump to content

encode ampersand in header


cberube09

Recommended Posts

Right, sorry, that what I meant, I just wrote the wrong thing.

 

This is the code with the url unencoded

header("Location:index.php?content=main&id=$categoryout&title=$titleout");

 

 

When I use anything like & or %26, that is what shows up in the URL when it redirects, not the regular &, so in turn, the page is not found.

Try:

 

header("Location: index.php?content=main&id=" . urlencode($categoryout) . "&title=" . urlencode($titleout));

 

 

And technically it should be something like:

 

 

header("Location: http://{$_SERVER['HTTP_HOST']}/index.php?content=main&id=" . urlencode($categoryout) . "&title=" . urlencode($titleout));

 

 

Since the HTTP specification says that Location is to specify a full URL, domain included.

Something like this...

index.php?content=main&id=Government_Policy&title=Hypocritical_Politicians

 

I want to encode the ampersands because that this is required by W3 specification.  Since the ampersand does not mean AND but is an operator in the link, it must be encoded.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.