jribeiro
jribeiro

Reputation: 3463

.htaccess losing URL parameters/$_GET and $_POST after redirect

I have a php file like: http://www.domain.com/?mod=test&act=view

And I want to create a redirection from that address to something like: http://www.domain.com/view-test

so that everytime a user accesses the first uri it gets redirected to http://www.domain.com/view-test viewing the content of the first uri.

I have the following rules:

RewriteCond %{QUERY_STRING} mod=test&act=view
RewriteRule ^$ view-test? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^view-test.html amas/index.php?mod=test&act=view [L]

This works fine for pages without parameters or forms submissions but If I have any of those nothing works.

Meaning that if I have a form that is submitting to the same file it won't work. If i have something like http://domain.com/?mod=test&act=view&order_by=id i'm left with the redirected to uri and the order_by parameter is ignored!

Is it even possible to do what I'm trying? I don't really know much about this and to be honest I'm lost between all the info I find... :/

Upvotes: 1

Views: 1110

Answers (1)

Pekka
Pekka

Reputation: 449475

Use Query String Append:

RewriteRule ^view-test.html amas/index.php?mod=test&act=view [L,QSA]

Upvotes: 1

Related Questions