0

I could not find a solution to this problem. Maybe because I don't know what to search for, but I am having difficulty setting up mod_rewrite.

I have URL example.com/soutez redirecting to example.com/soutez.php which is all fine and working using following settings:

RewriteRule ^soutez/?$ /soutez.php [L]

But the problem starts when I have a URL like example.com/sutaz?fbclid=1324 and someone sends a POST form, which adds custom parameter status=ok (like example.com/soutez?status=ok).

Then for example URL like example.com/soutez?fbclid=IwAR0GO5lq0VnVZS on form send transforms URL to example.com/soutez&fbclid=IwAR0GO5lq0VnVZS?status=ok which is weird and incorrect and shows 404 because it adds new parameters to the end and changes first ? with &.

Does anybody know how to setup .htaccess in order to make it work and let it show correctly example.com/soutez?fbclid=IwAR0GO5lq0VnVZS&status=ok?

Current .htaccess is as follows:

Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 
# Specify search friendly URLs
RewriteRule ^soutez/?$ /soutez.php [L]
MrWhite
  • 43,179
  • 8
  • 60
  • 84
Greenie
  • 13
  • 1
  • 1
  • 5
  • That seems unlikely. Only a look into the [rewrite log](https://stackoverflow.com/questions/9632852/how-to-debug-apache-mod-rewrite) can answer this though. – mario Mar 04 '19 at 23:21
  • Most problems with rewrites and query strings stem from not using the `QSA` flag – Phil Mar 08 '19 at 01:36
  • 1
    There's something else going on here - the problem is not with the `.htaccess` code you posted. It's not clear from your question how these "custom parameters" are being sent/received and managed? "URL like `example.com/soutez?fbclid=IwAR0GO5lq0VnVZS` on form send transforms URL to `example.com/soutez&fbclid=IwAR0GO5lq0VnVZS?status=ok`" - Where is `status=ok` coming from? – MrWhite Mar 08 '19 at 01:36
  • Also, using mod_rewrite to simply remove the need for a file-extension is overkill (in my opinion). That's what `MultiViews` is for – Phil Mar 08 '19 at 01:37

0 Answers0