Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect History: Update docs #748

Merged
merged 1 commit into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions docs/miscellaneous-options/read-redirect-history.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
title: Read redirect history
weight: 26
---

Sometimes it can happen that the screenshot made by Browsershot is different from the one displayed by your browser.
It is often due to one or more redirects made by the site, based on geolocation, cookies, etc...

To understand what happens, you can keep track of the redirects made by the site, both HTTP, Javascript and HTML ones.
In addition to the URLs there are also available HTTP status, reason and headers.

```php
$redirects = Browsershot::url('https://www.spatie.be')
->redirectHistory();

foreach ($redirects as $redirect) {
print $redirect['url'] . PHP_EOL;
print $redirect['status'] . PHP_EOL;
print $redirect['reason'] . PHP_EOL;
foreach ($redirect['headers'] as $name => $value) {
print $name . ' : ' . $value . PHP_EOL;
}
print PHP_EOL;
}
```