Metadata-Version: 2.4
Name: bear-django-remove-trailing-slash
Version: 0.1.0
Summary: A Django middleware that removes trailing slashes from URLs for SEO purposes.
Author-email: Bohdan Riabunets <bearablyk@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/bearablyk/django-remove-trailing-slash
Project-URL: Issues, https://github.com/bearablyk/django-remove-trailing-slash/issues
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Framework :: Django
Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: Django>=3.2

# Django Remove Trailing Slash

A simple Django middleware that enforces a "no trailing slash" policy by permanently redirecting (301) any URL ending in a slash to its non-slashed version.

This is useful for SEO purposes to prevent duplicate content indexing.

## Features

-   Performs a 301 Permanent Redirect.
-   Preserves query strings.
-   Ignores the root path (`/`).
-   Allows configurable exclusion of URL prefixes (e.g., `/admin/`, `/api/`).

## Installation

```bash
pip install bear-django-remove-trailing-slash
```

## Usage

1.  Add the middleware to your `MIDDLEWARE` list in `settings.py`. It is recommended to place it before Django's `CommonMiddleware`.

```python
# settings.py
MIDDLEWARE = [
   'remove_slash.middleware.RemoveTrailingSlashMiddleware',
    # ... other middleware
]
```

2.  (Optional) By default, the middleware ignores URLs starting with `/admin/`. You can customize this by adding `REMOVE_SLASH_IGNORE_PREFIXES` to your `settings.py`.

```python
# settings.py
REMOVE_SLASH_IGNORE_PREFIXES = ['/admin/', '/api/v1/']
```

That's it! The middleware will now automatically handle redirects.
