I have a URL that looks like this: mywebsite.com/mypage?lang=fr How can I remove the "?lang=fr" from the end with htaccess? I am not sure how to get it working.
Try using the following mod_rewrite rules: RewriteCond %{QUERY_STRING} ^lang=fr$ RewriteRule ^(.*)$ http://mywebsite.com/mypage? [R=301,L] Or, use the following mod_rewrite rules (removes the "lang=fr" query parameter from all requested URL-paths): RewriteCond %{THE_REQUEST} ^[A-Z]+\ /[^?]*\?(([^&]*)&)*lang=fr(&[\ ]*)?\ HTTP/ # accept optional parameters before 'lang=fr', but none after RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)?lang=fr$ [OR] # require parameters before and accept optional parameters after 'lang=fr' RewriteCond %{QUERY_STRING} ^(([^&]*(&[^&]*)*)&)lang=fr((&[^&]*)*)$ RewriteRule ^(.*)$ http://mywebsite.com/$1?%2%4 [R=301,L]
Hi, I've found this post while I was browsing the Web for a similar issue. Maybe someone here could help me solve it? On my website, I have a few URL that look like this: website.com/page?param=1 and they all give a 404 error. I don't want to remove the parameters but just ignore them to avoid the 404 error. How can I do this with htaccess? Here is my current .htaccess file: SetEnv PHP_VER 5 RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)$ index.php Code (markup): Sincerely, Amarillo