API client for the best htaccess tester in the world.

Fund package maintenance!

Installs: 15 971

Dependents: 1

Suggesters: 0

Security: 0

Stars: 8

Watchers: 11

Forks: 1

Open Issues: 2


v2.3.0 2021-11-26 12:52 UTC


Build status Latest Stable Version License codecov

This is an API client to interact with the Htaccess tester.


composer require madewithlove/htaccess-api-client


The package can be used with every PSR-compatible http client. In this example, we're going to be using guzzle's PSR adapter.

use Http\Factory\Guzzle\ServerRequestFactory;
use Http\Adapter\Guzzle6\Client;
use Madewithlove\HtaccessClient

$client = new HtaccessClient(
    new Client(),
    new ServerRequestFactory()

$response = $client->test(
    'RewriteRule .* /foo [R]'

$response->getOutputUrl(); // "http://localhost/foo"
array(1) {
  object(Madewithlove\ResultLine)#30 (5) {
    ["line":"Madewithlove\ResultLine":private]=> string(23) "RewriteRule .* /foo [R]"
    ["message":"Madewithlove\ResultLine":private]=> string(98) "The new url is http://localhost/foo
Test are stopped, a redirect will be made with status code 302"
    ["isMet":"Madewithlove\ResultLine":private]=> bool(true)
    ["isValid":"Madewithlove\ResultLine":private]=> bool(true)
    ["wasReached":"Madewithlove\ResultLine":private]=> bool(true)

Server variables

Htaccess Tester supports passing server variables to be evaluated by the rewrite rules. We currently support the following variables.

Server variables can be passed to the test() and share() methods.

$serverVariables = ServerVariables::default()->with(

$response = $client->test(
    'RewriteCond %{SERVER_NAME}
    RewriteRule .* /foo [R]',

$response = $client->share(
    'RewriteCond %{SERVER_NAME}
    RewriteRule .* /foo [R]',