Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5dc6753
Fix - CVE-2025-60868
Alt-Ben Oct 13, 2025
bd4a454
Create SECURITY.md
Alt-Ben Oct 13, 2025
0e85ac2
Statamic V6 support
Alt-Charlie Feb 16, 2026
c0e4939
Tweak assets
Alt-Charlie Feb 16, 2026
97cfa2a
Include prod assets
Alt-Charlie Feb 16, 2026
dd48ca0
Added return
Alt-Charlie Feb 16, 2026
909932c
Remedials
Alt-Charlie Feb 16, 2026
3711127
Remedials 2
Alt-Charlie Feb 16, 2026
16a7cfe
Remedials 3
Alt-Charlie Feb 16, 2026
c6a7cd3
Remedials 4
Alt-Charlie Feb 16, 2026
29ef77b
Merge pull request #41 from Alt-Charlie/DEV-3170
benmAltDesign Feb 17, 2026
a556234
feat: implementation
benmAltDesign Apr 9, 2026
ad26fd5
test: testing suite
benmAltDesign Apr 9, 2026
e713ae0
tests: split tests to individual files
benmAltDesign Apr 9, 2026
5d9338f
tests: further test coverage
benmAltDesign Apr 9, 2026
ea0dd1e
fix: addres sentry bug
benmAltDesign Apr 9, 2026
1d7e4ba
feat: run pest in an action on MR
benmAltDesign Apr 9, 2026
54fe008
fix: actions issue
benmAltDesign Apr 9, 2026
aea66fd
fix: 8.3 tests
benmAltDesign Apr 9, 2026
b4f9a0c
feat: Laravel Boost Skill
benmAltDesign Apr 9, 2026
cc59f28
docs: readme update to include database redirect documentation
benmAltDesign Apr 9, 2026
431a3d3
fix: addres query string installation and add test
benmAltDesign Apr 9, 2026
d736859
feat: regex redirect flagging
benmAltDesign Apr 9, 2026
d184b97
fix: address ID issue
benmAltDesign Apr 9, 2026
603e747
fix: database query strings issue
benmAltDesign Apr 9, 2026
bee8bdb
fix: fix simple redirect regression
benmAltDesign Apr 9, 2026
f29cf64
feat: better regex detection
benmAltDesign Apr 9, 2026
96d5f70
fix: address .installed issue
benmAltDesign Apr 9, 2026
abaf686
fix: address failing tests
benmAltDesign Apr 9, 2026
ec76f95
Merge pull request #44 from alt-design/feat/issue-#43-database-redirects
benmAltDesign Apr 16, 2026
e4cf693
Merge branch 'main' into feat/boost-tools
benmAltDesign Apr 16, 2026
be160ba
Merge pull request #45 from alt-design/feat/boost-tools
benmAltDesign Apr 16, 2026
69119fa
feat: per page options, pagination fix and build
benmAltDesign May 12, 2026
2f7d6bc
Merge pull request #46 from alt-design/feat/issue-#33-table-improvements
benmAltDesign May 12, 2026
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
33 changes: 33 additions & 0 deletions .github/workflows/pest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Pest Tests

on:
pull_request:
branches:
- main
- master

jobs:
test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [8.3]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-interaction --no-progress

- name: Run Pest tests
run: vendor/bin/pest
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
composer.lock
/node_modules
package-lock.json
/vendor
vite.hot
.DS_*
40 changes: 40 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,46 @@ On this page you can manage the query strings you wish to strip, simply :

You'll see your query string in the list.

### Database Redirects

By default, the addon stores redirects and query strings as YAML files in `content/alt-redirect/`. For containerised deployments or larger sites, you may wish to store these in your database instead.

#### 1. Publish Configuration
If you haven't already, publish the configuration file to your site:

```bash
php artisan vendor:publish --tag=alt-redirect-config
```

#### 2. Run Migrations
While migrations are loaded automatically, you can publish them if you wish to customize them:

```bash
php artisan vendor:publish --tag=alt-redirect-migrations
```

Run the migrations to create the necessary tables:

```bash
php artisan migrate
```

#### 3. Switch Driver
In your `config/alt-redirect.php`, change the `driver` from `file` to `database`:

```php
'driver' => 'database',
```

#### 4. Migrate Existing Data (Optional)
If you already have file-based redirects and want to move them to your database, you can use the following Artisan command:

```bash
php artisan alt-redirect:migrate-file-redirects
```

The command will check if the required tables exist and then migrate all your redirects and query strings.

#### Artisan Command

We have provided an Artisan command to force the creation of defaults.
Expand Down
30 changes: 30 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Reporting a Vulnerability

We take security very seriously at Alt Design. If you discover a potential security vulnerability in this project, please report it **privately** to us rather than opening a public issue.

### Contact

Please send all security reports to:

**Email:** ben@alt-design.net

Include as much detail as possible, such as:

- Steps to reproduce the issue
- Impact assessment
- Affected version(s)
- Any suggested mitigations (if known)

We will acknowledge receipt of your report promptly and keep you updated on progress.

### Response Time

We aim to respond within 48 hours. Critical vulnerabilities may receive priority handling.

### Public Disclosure

After a fix has been released and verified, we may publicly disclose the vulnerability in a security advisory. We will give credit to reporters unless they request anonymity.

### Security Updates

We publish security updates as new releases. We strongly recommend users upgrade to the latest version to stay protected.
16 changes: 14 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
"AltDesign\\AltRedirect\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"AltDesign\\AltRedirect\\Tests\\": "tests"
}
},
"require": {
"php": "^8.1",
"statamic/cms": "^4.0|^5.17.0"
"statamic/cms": "^6.0"
},
"extra": {
"statamic": {
Expand All @@ -24,7 +29,14 @@
},
"config": {
"allow-plugins": {
"pixelfear/composer-dist-plugin": false
"pixelfear/composer-dist-plugin": true,
"pestphp/pest-plugin": true
}
},
"require-dev": {
"laravel/pint": "^1.29",
"pestphp/pest": "^4.4",
"pestphp/pest-plugin-laravel": "^4.1",
"orchestra/testbench": "^11.1"
}
}
15 changes: 14 additions & 1 deletion config/alt-redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@
|
*/

'headers' => []
'headers' => [],

/*
|--------------------------------------------------------------------------
| Driver
|--------------------------------------------------------------------------
|
| Here you may specify the driver to use for storing redirects.
|
| Supported: "file", "database"
|
*/

'driver' => 'file',
// 'driver' => 'database',
];
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
"build": "vite build --mode production"
},
"devDependencies": {
"@vitejs/plugin-vue2": "^2.2.0",
"laravel-vite-plugin": "^0.7.2",
"vite": "^4.0.0"
"@statamic/cms": "file:./vendor/statamic/cms/resources/dist-package",
"laravel-vite-plugin": "^2.0.1",
"vite": "^7.3.1"
}
}
20 changes: 20 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<php>
<env name="APP_KEY" value="Ackf36aba21d46c79442a47231a670ff"/>
<env name="APP_ENV" value="testing"/>
<env name="DB_CONNECTION" value="testbench"/>
</php>
</phpunit>
13 changes: 13 additions & 0 deletions resources/blueprints/redirects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ tabs:
hide_display: false
width: 50
default: '301'
-
handle: is_regex
field:
type: toggle
display: 'Is Regex?'
instructions: 'Automatically detected, but can be overridden.'
listable: hidden
instructions_position: above
visibility: visible
replicator_preview: true
hide_display: false
width: 50
default: false
-
handle: sites
field:
Expand Down
139 changes: 139 additions & 0 deletions resources/boost/skills/crud-redirects/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
name: CRUD Redirects and Query Strings
description: The ability to CRUD redirects and query strings within the Alt Redirect addon.
---

### Domain Description
The Alt Redirect addon provides a flexible way to manage redirects and query strings in Statamic. It supports both file-based and database-based storage via a repository pattern.

### Key Components
- `AltDesign\AltRedirect\Contracts\RepositoryInterface`: The primary interface for data operations.
- `AltDesign\AltRedirect\Repositories\RepositoryManager`: Handles driver resolution.

### Basic CRUD Operations
You can perform operations on two types: `redirects` and `query-strings`.

#### Injecting the Repository
The `RepositoryInterface` is automatically bound to the active driver. You can inject it into your classes:

```php
use AltDesign\AltRedirect\Contracts\RepositoryInterface;

public function __construct(protected RepositoryInterface $repository)
{
}
```

#### Fetching All Data
To get all redirects or query strings:

```php
$redirects = $this->repository->all('redirects');
$queryStrings = $this->repository->all('query-strings');
```

#### Finding a Specific Item
To find a redirect by its `from` path:

```php
$redirect = $this->repository->find('redirects', 'from', '/old-url');
```

To find a query string by its key:

```php
$queryString = $this->repository->find('query-strings', 'query_string', 'utm_source');
```

#### Creating or Updating
To save data, pass the type and an array containing the item data.
**IMPORTANT:** Always provide an `id` (e.g., using `uniqid()`) when creating new items to ensure compatibility across all storage drivers and to allow for future updates.

**Redirect Example:**
```php
$this->repository->save('redirects', [
'id' => uniqid(),
'from' => '/example-from',
'to' => '/example-to',
'redirect_type' => '301',
'sites' => ['default']
]);
```

**Query String Example:**
```php
$this->repository->save('query-strings', [
'id' => uniqid(),
'query_string' => 'new_param',
'strip' => true,
'sites' => ['default']
]);
```

#### Deleting
To delete an item, pass the type and an array containing at least the `id`, `from`, or `query_string` key.

```php
// Delete redirect by ID
$this->repository->delete('redirects', ['id' => '69d767de74f05']);

// Delete redirect by path
$this->repository->delete('redirects', ['from' => '/example-from']);

// Delete query string by name
$this->repository->delete('query-strings', ['query_string' => 'new_param']);
```

### Advanced Operations
#### Regex Redirects
To get only the redirects that are intended for regex matching (often those containing regex patterns in the `from` field):

```php
$regexRedirects = $this->repository->getRegex('redirects');
```

#### Bulk Saving
To save multiple items at once:

```php
$this->repository->saveAll('redirects', [
['from' => '/a', 'to' => '/b', 'redirect_type' => '301', 'sites' => ['default']],
['from' => '/c', 'to' => '/d', 'redirect_type' => '302', 'sites' => ['default']],
]);
```

### Verifying Operations
After creating or modifying a redirect, you can verify it in several ways:

#### 1. Direct Storage Check
- **File Driver**: Check for a YAML file in `content/alt-redirect/`. The filename is typically a hash of the `from` URL or its base64 encoding.
- **Database Driver**: Use a database tool to query the `alt_redirects` or `alt_query_strings` tables.

#### 2. Using CURL
You can test if the redirect is working by making a request to the `from` path:
```bash
curl -I http://your-site.test/old-url
```
A successful redirect should return a `301 Moved Permanently` or `302 Found` status with a `Location` header pointing to the new URL.

#### 3. Repository Check
You can also use the repository's `find` or `all` methods in a test or via Tinker to confirm the data was saved correctly.

### Site Configuration
Redirects and query strings are site-specific. You must provide a list of site handles in the `sites` array.

#### Obtaining Site List
To get the list of available site handles in the current Statamic installation, you can use Tinker:
```php
php artisan tinker --execute="print_r(Statamic\Facades\Site::all()->map->handle()->toArray())"
```
Or within your code:
```php
use Statamic\Facades\Site;
$siteHandles = Site::all()->map->handle()->all();
```

### Implementation Details
- **File Driver**: Stores data as YAML files in `content/alt-redirect/`.
- **Database Driver**: Uses `alt_redirects` and `alt_query_strings` tables.
- **Multisite**: Both types include a `sites` array which should contain the handles of the Statamic sites where the redirect or query string rule applies.
1 change: 0 additions & 1 deletion resources/dist/build/assets/alt-redirect-addon-4ed993c7.js

This file was deleted.

Loading