I'm not very experienced with .htaccess and I'm having some difficulty rewriting the URLs of a site.
In the site in question, I first forced the rewrite of the URL to HTTPS (the site did not have SSL before):
Options +FollowSymlinks
ErrorDocument 404 https://www.dominio.com.br/pagina404.html
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Then I successfully redirected domain.com to www.domain.com . The rule also applies to index or index.php after the base URL (eg www.domain.com/index.php).
RewriteCond %{HTTP_HOST} ^dominio\.com\.br
RewriteRule ^(.*) https://www.dominio.com.br/$1 [R=301,L]
RewriteRule ^index(/|.php)?$ https://www.dominio.com.br [R=301,L]
So far, everything worked. It turns out that the URLs on this site are not user friendly. They follow the pattern below:
www.dominio.com.br/index.php?link=sobre
As the rewrite removes the index, it looks like this: www.dominio.com.br/?link=sobre
So I force the rewrite using the snippet below, to try a URL like this: www.domain.com / over
RewriteRule ^\?link=(.*) /$1
RewriteRule ^/(.*)(.php)?\?link=(.*) /$3
This was one of the rules I tried, including testing on Sublime / netBeans, using their regex module, working right there. It happens that when I test on the server, no rewrite occurs. I have tested several other rules by reading the documentation, like [NC], [L] and others. Some result in a 500 error.
So my question is whether using HTTPs, deleting the index, or the server itself might be affecting these rewrites?
Note: I tried some of the options shown in other topics, like these: