I've read through about 6 or 7 suggested similar post but still can't get this working.
(e.g.: Reference: mod_rewrite, URL rewriting and "pretty links" explained / How to write htaccess rewrite rule for seo friendly url etc...)
I have a PHP website with a help articles section, which pulls the content from the db by article id. Current URL format =
/sitename/help.php?h=69
I'd like to change the URL format to:
/sitename/help/69/title-of-the-article
Mod_rewrite is enabled on the server, and this seems to work:
RewriteRule ^help/([0-9]+)/?(.*)/?$ /sitename/help.php?h=$1 [NC,L]
/sitename/help/69/random-title
loads the content for /sitename/help.php?h=69
However, some of the articles contain images, coming from the path /sitename/images/
The modified URL means the browser tries to call /sitename/images/example.jpg
from sitename/help/69/images/example.jpg
The '69' is an unknown variable, (and that seems to break all the examples I've tried!), but should always be a 1, 2 or 3 digit number.
Please can someone help with the rewrite/regex query to remove the /help/{article id}/
from my image URLs?