Apache .htaccess Clean URL Rewrite

Замовник: AI | Опубліковано: 01.04.2026

I have built a small portfolio site in PHP, HTML & CSS that runs on an Apache server and stores its content in a MySQL database. Right now, every public link still carries query-strings—e.g. mydomain/image.php?id=6 I want this turned into true, SEO-friendly paths–e.g. mydomain/image/6/My-Image-Title I've created a database field to store the [slug] value that will be used as My-Image-Title In addition, I’d like all remaining .php and .html extensions stripped cleanly, so visitors (and search engines) never see a file suffix. What I need from you is a set of RewriteRule and RewriteCond directives—regular-expression based, ready to drop into my .htaccess file—that: 1. Translate the current query-string format to the clean structures shown above. 2. Handle both numeric IDs and human-readable titles safely (including dashes or underscores). 3. Issue proper 301 redirects so no old link returns a 404. 4. Leave room for me to add future sections that may follow the same pattern. I have attempted some of the above work on my own; however, I am unable to get it to work on the web server. The issue may be caused by a conflict with other regex commands in the existing .htaccess file.