aklump/htaccess-manager

Fund package maintenance!
Buy Me A Coffee

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:project

0.0.4 2024-12-11 04:38 UTC

This package is auto-updated.

Last update: 2024-12-11 04:39:52 UTC


README

htaccess

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

  • 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

  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 --dev aklump/htaccess-manager:^0.0
    

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

  • To view help execute ./vendor/bin/htaccess

Sponsor this project

 github.com  buymeacoffee.com  paypal.com

More Reading

Troubleshooting

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?