P
P
private132020-05-27 13:05:03
htaccess
private13, 2020-05-27 13:05:03

How to fix url via htaccess?

Good afternoon, respected masters of their craft. I need help setting up the htaccess file.

Given.
Link https://sitename.ru/docs.php?lang=en

Need to get it.
Link https://sitename.ru/docs.php
Any page that has ?lang=en in the address bar is replaced (or redirected) to the same string, but without ?lang=en

Current file:

RewriteEngine On

RewriteCond %{ HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{HTTP_HOST} ^www.sitename.ru$ [NC]
RewriteRule ^(.*)$ https://sitename.ru/$1 [R=301,L]

RewriteCond %{REQUEST_URI} ^(.*)/index.php$
RewriteRule ^(.*)$ %1/ [R=301,L]

RewriteRule ^index\.php$ https://sitename.ru/ [L,R=301]
ErrorDocument 404 https://sitename.ru/404 .php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-05-29
@privat13

RewriteCond %{QUERY_STRING} (^|&)lang\=en($|&)
RewriteRule ^(.*)$ /%1? [L,R=301]

GET is not part of the url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question