PHPackages                             aklump/htaccess-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. aklump/htaccess-manager

ActiveProject[Utility &amp; Helpers](/categories/utility)

aklump/htaccess-manager
=======================

0.0.9(4mo ago)027[1 issues](https://github.com/aklump/htaccess-manager/issues)BSD-3-ClausePHPPHP &gt;=7.4

Since Nov 26Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/aklump/htaccess-manager)[ Packagist](https://packagist.org/packages/aklump/htaccess-manager)[ Fund](https://www.buymeacoffee.com/aklump)[ RSS](/packages/aklump-htaccess-manager/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (10)Used By (0)

Htaccess Manager
================

[](#htaccess-manager)

[![htaccess](images/htaccess.jpg)](images/htaccess.jpg)

Summary
-------

[](#summary)

A PHP tool for .htaccess management in your web projects.

- Allows you to include *.htaccess* files in other *.htaccess* files.
- Work with smaller files then combine using `./bin/htaccess build`
- Share common snippets across different *.htaccess* files.
- Simplified URL redirection; remap old URLs to new without nasty syntax.
- Merge in remote *.htaccess* source files on build (think Drupal web root *.htaccess* + custom *.htaccess* directives).
- Manage banned IPs in a separate file or add them to the YAML configuration.

Quick Start
-----------

[](#quick-start)

- Create a YAML configuration file in a secure location in your project.
- Refer to *config.example.yml* as a guide and optionally, delete when done.
- Lastly, build your files using `./vendor/bin/htaccess build path/to/your/config.yml`

Install with Composer
---------------------

[](#install-with-composer)

1. This package requires some unpublished packages. You must add the following to *composer.json* in the `repositories` array:

    ```
    {
     "type": "github",
     "url": "https://github.com/aklump/json-schema-loading"
    },
    {
     "type": "github",
     "url": "https://github.com/aklump/json-schema-validation"
    },
    {
     "type": "github",
     "url": "https://github.com/aklump/json-schema-merge"
    }
    ```
2. Require this package:

    ```
    composer require aklump/htaccess-manager:^0.0

    ```

Configuration Special Notes
---------------------------

[](#configuration-special-notes)

- You must list one or more hosts in `valid_hosts`, including their http or https protocol.
- Forced SSL redirection is detected based on the `valid_hosts` array; `force_ssl` will be set to `true` if all `valid_hosts` use the *https* protocol. You may override auto-detection by setting `force_ssl` to `true` or `false`.
- Adding or removing `www.` is detected based on the `valid_hosts` array. It is set to `add` if all `valid_hosts` have `www.`, `remove` if all `valid_hosts` do not have `www.`. When neither `add` nor `remove` no redirection takes place. You may override auto-detection by setting `www_prefix` to `add`, `remove`, or `default`.

Usage
-----

[](#usage)

- To view help execute `./vendor/bin/htaccess`

Environment Variable Substitution
---------------------------------

[](#environment-variable-substitution)

The configuration file supports environment variable substitution. You can use `$VAR_NAME` or `${VAR_NAME}` syntax in both keys and values of the YAML file. Using `${VAR_NAME}` is recommended to avoid ambiguity when a variable is immediately followed by other characters. This is useful for creating template-like configurations that can be customized per project.

```
files:
  ${PROJ_ID}:
    title: $PROJ_TITLE
    valid_hosts:
      - https://example.com
    output:
      - ${PROJ_DIR}/web/.htaccess
```

When running the build command, provide the environment variables:

```
PROJ_ID=myproject PROJ_TITLE="AKlump's Web Factory" PROJ_DIR=./path ./bin/htaccess build config.yaml
```

Sponsor this project
--------------------

[](#sponsor-this-project)

 [github.com](https://github.com/sponsors/aklump)

 [buymeacoffee.com](https://buymeacoffee.com/aklump)

 [paypal.com](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4E5KZHDQCEUV8&item_name=Open%20Source%20Sponsorship)

More Reading
------------

[](#more-reading)

- [THE Ultimate Htaccess](https://www.askapache.com/htaccess)
- [Mod\_Rewrite Variables Cheatsheet](https://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet/)
- [Htaccess](https://www.askapache.com/category/htaccess/)

Troubleshooting
---------------

[](#troubleshooting)

### 4xx redirects are not working

[](#4xx-redirects-are-not-working)

I'm not sure why, but on some servers they do not work. Possible reasons:

1. Apache version?
2. VirtualHost config hijacking?
3. Drupal conflict?

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance75

Regular maintenance activity

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~103 days

Total

9

Last Release

138d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/79476f3b82f9c766433c7eb401cbcfc636cd5d5ccf2b2e6b50ea81d1de6c2730?d=identicon)[aklump](/maintainers/aklump)

---

Top Contributors

[![aklump](https://avatars.githubusercontent.com/u/425737?v=4)](https://github.com/aklump "aklump (56 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aklump-htaccess-manager/health.svg)

```
[![Health](https://phpackages.com/badges/aklump-htaccess-manager/health.svg)](https://phpackages.com/packages/aklump-htaccess-manager)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M420](/packages/drupal-core-recommended)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
