问题原文
原帖链接 · Mantykora 7 · CC BY-SA 4.0
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
- htaccess
RewriteRule ^show_user.html/(\d+)$ show_user.php?id=$1 [NC,L]
profile.php
After update user -> redirect to user detail
redirect_to(url_for('/user_profile/show_user.html/' . $id));
已采纳解答
原帖链接 · MrWhite · CC BY-SA 4.0
I want to have
public/user_profile/show_user.html/4RewriteRule ^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.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
