M
M
Maxim Khramov2016-02-15 14:10:30
Apache HTTP Server
Maxim Khramov, 2016-02-15 14:10:30

How to remove the appearing get parameters on 301 redirects via .htaccess?

Good afternoon!
Changed server. The previous server used the Apache 1.3 web server, after the migration Apache 2.2 is used.
The CNC is working fine, but 301 redirects started adding "tail" from the get parameters.
I understand that the new Apache handles redirects differently, but I don't know how to fix it. It is necessary that the "tail" from get ceases to be added.
.htaccess file:

RewriteEngine On

RewriteBase /

RewriteCond %{HTTP_HOST} !www.site.ru
RewriteRule (.*) http://www.site.ru/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule .+ - [L]

RewriteRule ^([^/]+)/(.*)/(.*)/(.*)/(.*).htm(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4&last=$5 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)/(.*).htm(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*).htm(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3 [QSA,L]
RewriteRule ^([^/]+)/(.*).htm(.*)$ /index.php?lang=ru&module=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+).htm(.*)$ /index.php?lang=ru&module=$1 [QSA,L]

RewriteRule ^([^/]+)/(.*)/(.*)/(.*)/(.*)/$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4&last=$5 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)/(.*)/(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4&last=$5 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)/(.*)/$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)/(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3&subsublevel=$4 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)/$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3 [QSA,L]
RewriteRule ^([^/]+)/(.*)/(.*)$ /index.php?lang=ru&module=$1&id=$2&sublevel=$3 [QSA,L]
RewriteRule ^([^/]+)/(.*)/$ /index.php?lang=ru&module=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+)/(.*)$ /index.php?lang=ru&module=$1&id=$2 [QSA,L]
RewriteRule ^([^/]+)$ /index.php?lang=ru&module=$1 [QSA,L]

Redirect 301 /basket.htm http://www.site.ru/order.htm
Redirect 301 /cat/1811.htm http://www.site.ru/cat/1485.htm
Redirect 301 /cat/1811/196900.htm http://www.site.ru/cat/1485/172914.htm
Redirect 301 /cat/1811/196871.htm http://www.site.ru/cat/1485/172914.htm
Redirect 301 /cat/1811/196631.htm http://www.site.ru/cat/1485/172914.htm

Update:
Clarification. Only the redirects listed below started to be processed incorrectly:
Redirect 301 /basket.htm http://www.site.ru/order.htm
Redirect 301 /cat/1811.htm http://www.site.ru/cat/1485.htm
Redirect 301 /cat/1811/196900.htm http://www.site.ru/cat/1485/172914.htm
Redirect 301 /cat/1811/196871.htm http://www.site.ru/cat/1485/172914.htm
Redirect 301 /cat/1811/196631.htm http://www.site.ru/cat/1485/172914.htm

Update2:
I got stackoverflow.com and the only solution that came up for me was to change the redirect to RewriteRule and move it to the beginning. If anyone knows a better solution, I'd be happy to hear it.
RewriteEngine On
RewriteRule ^/?basket.htm$ http://www.site.ru/order.htm? [R=301,L]
RewriteRule ^/?cat/1811.htm$ http://www.site.ru/cat/1485.htm? [R=301,L]
RewriteRule ^/?cat/1811/196900.htm$ http://www.site.ru/cat/1485/172914.htm? [R=301,L]
RewriteRule ^/?cat/1811/196871.htm$ http://www.site.ru/cat/1485/172914.htm? [R=301,L]
RewriteRule ^/?cat/1811/196631.htm$ http://www.site.ru/cat/1485/172914.htm? [R=301,L]
RewriteRule ^/?cat/1811/196602.htm$ http://www.site.ru/cat/1485/172914.htm? [R=301,L]
RewriteRule ^/?cat/1811/209251.htm$ http://www.site.ru/cat/1485/209134.htm? [R=301,L]
RewriteRule ^/?cat/1811/182989.htm$ http://www.site.ru/cat/1485/171792.htm? [R=301,L]
RewriteRule ^/?cat/1811/183153.htm$ http://www.site.ru/cat/1485/171237.htm? [R=301,L]
RewriteRule ^/?cat/1811/207975.htm$ http://www.site.ru/cat/1485/167128.htm? [R=301,L]
RewriteRule ^/?cat/1811/202143.htm$ http://www.site.ru/cat/1485/194430.htm? [R=301,L]
RewriteRule ^/?cat/1811/197326.htm$ http://www.site.ru/cat/1485/168958.htm? [R=301,L]

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey, 2016-02-15
@VladimirAndreev

RewriteRule (.*) www.site.ru [R=301,L]

V
Viktor Taran, 2016-02-26
@shambler81

issue not resolved yet?
So remove the get in general
- pay attention to the question at the end, it will remove the get
if you need to work with the get itself and remove some of them, then this is a slightly wrong question
. RewriteRule works with the url, the get is not part of it in principle.
Vmm need a two-level design

# 301 --- http://shop.wildorchid.ru/Catalog/StyleCard.aspx?&shop=2&categoryid=2046&style=27600 => http://shop.wildorchid.ru/catalog/trusy/1465-vendetta/?show_all=N&arrFilter_199_447073417=Y&arrFilter_P1_MIN=500&arrFilter_P1_MAX=1399&CHECK_PRICE=N&orderBy=new_desc&set_filter=Y
RewriteCond %{QUERY_STRING} (^|&)shop=2($|&)
RewriteCond %{QUERY_STRING} (^|&)categoryid=2046($|&)
RewriteCond %{QUERY_STRING} (^|&)style=27600($|&)
RewriteRule ^Catalog/StyleCard\.aspx$ /catalog/trusy/1465-vendetta/?show_all=N&arrFilter_199_447073417=Y&arrFilter_P1_MIN=500&arrFilter_P1_MAX=1399&CHECK_PRICE=N&orderBy=new_desc&set_filter=Y [L,R=301]

Well, yes, a redirect to a get request, so you need to change ? to # and you will be happy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question