=== Flex Redirects ===
Contributors: flexfields
Tags: redirect, 301, 404, seo, urls
Requires at least: 6.2
Tested up to: 7.0
Requires PHP: 7.4
Stable tag: 1.3.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Manage 301/302/307 redirects, log hits with referrer and user info, and turn 404s into permanent moves.

== Description ==

**Flex Redirects** sends visitors from an old path to a new URL before the theme loads. Use it after migrations, slug changes, or when you retire pages.

* Exact, prefix, and regex matching
* Regex targets can reuse capture groups with `$1` or `${1}`
* 301, 302, and 307 status codes
* Optional query-string matching and passthrough
* Hit counters per redirect
* Hits Log with referrer, IP, user agent, and logged-in user (latest 5000)
* Optional 404 logging (latest 1000 HTML/permalink paths)
* CSV import (upsert) and export
* Dry-run tester for a path or URL
* Sortable columns and pagination on every list
* Clean uninstall removes tables and options

No remote calls. Rules and logs stay in your WordPress database. CSS and JavaScript are loaded from this plugin only.

= Privacy =

Flex Redirects stores redirect rules and optional 404 paths in your WordPress database.

When **Log redirect hits** is enabled (on by default), it also stores per-hit visitor data: IP address, HTTP referrer, user agent, and WordPress user ID if the visitor is logged in. Only administrators can view this log. Disable the setting if you do not need visitor-level history; aggregate Hits counters still update.

The plugin does not send data to external servers and does not load third-party scripts.

== Installation ==

1. Upload the `flex-redirects` folder to `/wp-content/plugins/`, or install the zip via **Plugins → Add New → Upload Plugin**.
2. Activate **Flex Redirects**.
3. Go to **Flex Redirects → All Redirects** and add your first rule.
4. Confirm with **Tools → Test a path**, or visit the old URL in a private window.

== Frequently Asked Questions ==

= Does this replace an SEO plugin? =

No. Use Flex Redirects for URL redirects. Pair it with Flex SEO (or another SEO plugin) for titles, meta tags, and sitemaps.

= How do regex replacements work? =

Use match type Regex with a pattern such as `^/blog/(.*)$` and a target like `/news/$1`. Enter the pattern without `#` delimiters. Invalid patterns are rejected when you save.

= Can I redirect to another domain? =

Yes. Put a full `https://` URL in Target. Only `http` and `https` destinations are allowed.

= What is stored in the Hits Log? =

Time, source, target, status code, logged-in user (or Guest), referrer, IP, and user agent. The log keeps about the latest 5000 rows. Turn it off under Settings if you do not need that history.

= Will this conflict with another redirect plugin? =

Possibly. If two plugins try to redirect the same path, the one that runs first wins. Disable overlapping rules, or use **Tools → Test a path** to see what Flex Redirects would do.

= What happens when I uninstall? =

Deleting the plugin drops the redirect tables, hits log, 404 log, and settings. Deactivating alone keeps your data.

== Screenshots ==

1. All Redirects — add a rule and manage the list
2. Hits Log — each redirect with user, referrer, and IP
3. 404 Log — missing paths you can turn into redirects
4. Tools — CSV import/export and path tester
5. Settings — query string, 404 log, and hit logging

== Changelog ==

= 1.3.0 =
* WordPress.org submission hygiene: http(s)-only destinations, no inline JavaScript, CSV size/row limits.
* About page links only to Flex plugins already listed on WordPress.org.
* Sync Stable tag with plugin version; expand readme privacy and FAQ.

= 1.2.2 =
* Align sort arrows with column headers.

= 1.2.1 =
* Sortable columns and always-visible pagination (20/50/100 per page) on All Redirects, Hits Log, and 404 Log.

= 1.2.0 =
* Add Hits Log: each redirect with user, referrer, IP, and user agent.
* Setting to enable/disable hit logging (keeps latest 5000 rows).
* Link rule hit counts on All Redirects into the filtered Hits Log.

= 1.1.1 =
* Exact rules with a query string match on the path when “Ignore query string” is on.
* Prefix rules append the unmatched suffix (folder move) and reject source /.
* Redirect GET/HEAD only; skip login, feeds, and the Flex SEO sitemap.
* Insert query strings before URL fragments; validate regex on save; upsert 404 hits.
* Expand the Usage page with match types, query strings, 404 log, CSV, and tester details.

= 1.1.0 =
* Fix regex sources, prefix path boundaries, subdirectory installs, and query-string matching.
* Skip self-redirects and in-request loops; continue to the next rule.
* CSV import upserts by source and match type; schema upgrades on plugin update.
* Add regex `$1` targets, query passthrough, 404 static-file filter, pagination, and a dry-run tester.

= 1.0.2 =
* Refreshed admin UI with a cleaner, card-based layout (local CSS only).

= 1.0.1 =
* Fix admin layout overlap on the redirects screen.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 1.3.0 =
Ready for WordPress.org: safer redirect targets, CSV limits, and a complete readme. Existing rules are unchanged.
