I don't know why but this htaccess item doesn't work for me. I have something like this after update user profile public/user_profile/show_user.html?id=4 and I want to have public/user_profile/show_user.html/4

  1. htaccess

RewriteRule ^show_user.html/(\d+)$ show_user.php?id=$1 [NC,L]

  1. profile.php

    After update user -> redirect to user detail

redirect_to(url_for('/user_profile/show_user.html/' . $id));

1 Answer 1


I want to have public/user_profile/show_user.html/4

RewriteRule ^show_user.html/(\d+)$ show_user.php?id=$1 [NC,L]

Assuming public/ is the document root and this .htaccess file is in the document root then you are missing /user_profile from the start of the RewriteRule pattern. For example:

RewriteRule ^user_profile/show_user\.html/(\d+)$ show_user.php?id=$1 [L]

Don't forget to backslash escape literal dots. You shouldn't need the NC flag here.

This directive also needs to be near the top of your .htaccess file, before any front-controller. Order matters.

  • 1
    Of course I'm in a different place :) As always, thanks for your help MrWhite:) Commented Feb 1, 2021 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.