Reputation: 1939
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]
Upvotes: 0
Views: 100
Reputation: 19016
You can use QSA flag to add query string to your forwarded page
RewriteRule ^staff/(new|edit|delete)$ /staff.php?action=$1 [L,QSA]
Upvotes: 2