So my staff.php?action=[action]
file is rewritten to /staff/[action]
where action
can take 3 values new/edit/delete
.
I want to display success or failure messages on submission. I tried to redirect to /staff/new&error=[error]
or /staff/new?error=[error]
.
However, the var_dump($_GET)
only returns the action
's query string.
The only solution I found is /staff?action=[action]&error=[error]
, but I don't like it. Is there any way of rewriting my rules?
I don't want /staff/new/error/[error]
## hide .php extension snippet
# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
# To internally forward /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
RewriteRule ^staff/(.+)$ /staff.php?action=$1 [L]
您可以使用QSA标志将查询字符串添加到转发的页面
RewriteRule ^staff/(new|edit|delete)$ /staff.php?action=$1 [L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.