JVC
JVC

Reputation: 783

Using PHP, edit or change the user agent before redirecting?

I'm redirecting traffic to another website, but they have some filtering in place that is rejecting a portion of the traffic. From what I understand, they're parsing the user agent string and refusing certain browsers. I'd like to be able to filter the UAs on my side first and replace them as needed before redirecting them.

So far I have tried this:

ini_set('user_agent', "my user agent");

but it doesn't seem to actually change anything when the redirection occurs.

Is it possible to even do this? Is it more of a Javascript thing since the UA is set in the browser?

I appreciate any ideas... thanks!

Upvotes: 1

Views: 1940

Answers (3)

AMayer
AMayer

Reputation: 355

the other website is probably parsing the header which the users browser is submitting. therefore it isn't posible to change the user agent

Upvotes: 0

Dan Soap
Dan Soap

Reputation: 10248

You cannot influence a browser's user agent setting from within a php script. I also doubt, that it is possible using JavaScript. However, what you might do is set up a proxy php script, which performs the requests to the remote site from your server and set the user agent of your script according to what you already tried (using ini_set).

Upvotes: 2

SeanCannon
SeanCannon

Reputation: 77956

That's not how redirects work. The remote server will still get the user agent from the client's machine. Setting your own user agent would be applicable if your server was making a cURL request - then it is acting as the client.

Upvotes: 5

Related Questions