From 1abe5218ca5ba1f016189580f7bc36327f477cc9 Mon Sep 17 00:00:00 2001 From: Ty Clifford Date: Wed, 24 Jun 2026 13:16:55 -0400 Subject: [PATCH] - Implemented configurable public URL rewriting. What changed: Added pretty URL helpers/default setting in [includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php). Added root rewrite rules in [.htaccess](/Users/tyemeclifford/Documents/GH/mediaplayer/.htaccess):/v/ /all /search/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added Admin → Settings “Public URL Style” toggle in [admin/settings.php](/Users/tyemeclifford/Documents/GH/mediaplayer/admin/settings.php), defaulting to pretty URLs. Updated public/player/catalogue/embed/admin preview links to use the configured URL style. Added redirects from legacy ?v= and ?q= URLs to pretty routes when rewriting is enabled. Documented deployment and fallback behavior in [README.md](/Users/tyemeclifford/Documents/GH/mediaplayer/README.md). --- .htaccess | 10 ++++ README.md | 14 +++++- admin/add.php | 2 +- admin/edit.php | 2 +- admin/index.php | 2 +- admin/login.php | 2 +- admin/settings.php | 14 +++++- admin/youtube_import.php | 2 +- catalogue.php | 29 +++++++++-- embed.php | 2 +- includes/db.php | 104 +++++++++++++++++++++++++++++++++++++++ includes/layout.php | 6 +-- index.php | 28 +++++------ 13 files changed, 187 insertions(+), 30 deletions(-) create mode 100644 .htaccess diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..9d6257c --- /dev/null +++ b/.htaccess @@ -0,0 +1,10 @@ +DirectoryIndex index.php + + + RewriteEngine On + + RewriteRule ^v/([^/]+)/?$ index.php?v=$1 [B,L,QSA] + RewriteRule ^all/?$ catalogue.php [L,QSA] + RewriteRule ^search/?$ catalogue.php [L,QSA] + RewriteRule ^search/(.+)/?$ catalogue.php?q=$1 [B,L,QSA] + diff --git a/README.md b/README.md index 411c31a..4a03ae5 100644 --- a/README.md +++ b/README.md @@ -8,13 +8,14 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. ## Requirements - PHP 8.0+ with `pdo_sqlite`, `fileinfo` extensions +- Apache `mod_rewrite` for default pretty URLs, or switch to query URLs in Admin → Settings - Write permissions on the `data/` and `media/` directories --- ## Installation -1. **Upload** all files to your web server (e.g. `/live/` or wherever `/index.php` lives). +1. **Upload** all files to your web server. To use domain-level pretty URLs such as `/v/my-video`, deploy the app at the web root. 2. **Set permissions** so PHP can write to these directories: ```bash @@ -36,6 +37,7 @@ Styled to match the existing `gate.php` / `index.php` dark theme exactly. / ← web root (deploy here) ├── index.php ← Main player + catalogue (home page) ├── catalogue.php ← Full video catalogue browse page +├── .htaccess ← Pretty URL rewrite rules ├── includes/ │ ├── db.php ← SQLite bootstrap + helper functions │ └── layout.php ← Shared HTML head, topbar, footer, pagination @@ -84,6 +86,16 @@ Use **Admin → YouTube Importer** to paste a YouTube channel URL, `@handle`, or The full catalogue page includes a public search for published videos only. Search matches video title, description, and slug; draft videos remain hidden. +### Public URLs + +Pretty URLs are enabled by default: + +- `/v/` plays a video +- `/all` lists all public videos +- `/search/` searches public videos + +You can switch to PHP query URLs in **Admin → Settings → Public URL Style** if your host does not support `.htaccess` rewrites. + ### Catalogue Per-Page Configurable in **Admin → Settings → Videos per page** (1–50). diff --git a/admin/add.php b/admin/add.php index 5c85856..e7c1037 100644 --- a/admin/add.php +++ b/admin/add.php @@ -170,7 +170,7 @@ render_head('Add Video — Admin', '