Jeff Jeff - 11 months ago 49
PHP Question

htaccess Page Redirect to URL with no page ID

This URL

needs to be redirected to this URL

Here is another example:


The client wants the page id removed from the URL. Can this redirect be done in the htaccess file or do I need to do it using PHP?

Answer Source

Yes, it can be done using a RedirectMatch rule.

Place this rule in your site root .htaccess:

RedirectMatch 301 ^/(articles)/\d+-(.+)$ /$1/$2