https://my-site.ru/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft
https://my-site.ru/catalog/bdsm-kostumi/maski-s-klapom/brand/microsoft/
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^catalog/.+/$ https://my-site.ru/$0%1/%2/? [R=301,L]
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)brand=([-0-9a-z]+)
RewriteRule (.*[^/])/*$ /$1/brand/%2/? [R=301]
https://my-site.ru/bitrix/urlrewrite.php/brand/microsoft/
нужно ставить правило редиректа в начало файла .htaccess чтобы редирект был выше остальных правил.
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^catalog/.+/$ /$0%1/%2/? [R=301,L]
https://my-site.ru/catalog/
https://my-site.ru/en/catalog/
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^catalog/.+/$ /$0%1/%2/? [R=301,L]
https://my-site.ru/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft
https://my-site.ru/catalog/bdsm-kostumi/maski-s-klapom/brand/microsoft/
https://my-site.ru/en/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft
https://my-site.ru/en/catalog/bdsm-kostumi/maski-s-klapom/brand/microsoft/
https://my-site.ru/catalog/?brand=microsoft
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^(en/)?catalog/(.+/)?$ /$0%1/%2/? [R=301,L]
https://my-site.ru/en/catalog/bdsm-kostumi/maski-s-klapom/brand/microsoft/?/
Используется один Apache или связка Nginx + Apache
какой версии
Server version: Apache/2.4.6 (CentOS)
Server built: Apr 5 2023 17:18:30
Server version: Apache/2.4.6 (CentOS)
Server built: May 30 2023 14:01:11
nginx version: nginx/1.20.2
nginx version: nginx/1.24.0
curl -I -H 'Host: my-site.ru' 'http://127.0.0.1:7080/catalog/?brand=microsoft'
curl -I -H 'Host: my-site.ru' 'http://127.0.0.1:7080/en/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft'
Посмотреть на каком порту слушает Apache
curl -I 'http://127.0.0.1:80/en/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft'
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Wed, 08 May 2024 12:38:28 GMT
Content-Type: text/html; charset=iso-8859-1
Connection: keep-alive
Location: http://127.0.0.1/en/catalog/bdsm-kostumi/maski-s-klapom/brand/microsoft/%3f
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
HTTP/1.1 301 Moved Permanently
Server: nginx
Date: Thu, 02 May 2024 11:07:40 GMT
Content-Type: text/html
Content-Length: 162
Connection: keep-alive
Location: https://127.0.0.1/en/catalog/bdsm-kostumi/maski-s-klapom/?brand=microsoft
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
в заголовках ответов Server: nginx, а не Server: Apache
HTTP/1.1 301 Moved Permanently
Date: Wed, 08 May 2024 12:59:55 GMT
Server: Apache
Location: http://127.0.0.1:8887/catalog/elektroinstrument/brand/bahco/%3f
Connection: close
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 301 Moved Permanently
Date: Thu, 02 May 2024 11:30:58 GMT
Server: Apache
Location: http://127.0.0.1:8888/catalog/elektroinstrument/brand/bahco/
Connection: close
Content-Type: text/html; charset=iso-8859-1
Нужно глянуть на тестовом сервере что в
# Ansible managed
# site: my-site
<VirtualHost 127.0.0.1:8887>
ServerName my-site
ServerAlias www.my-site
ServerAdmin webmaster@localhost
DocumentRoot /home/bitrix/ext_www/my-site.ru
ErrorLog logs/my-site_error_log
LogLevel warn
CustomLog logs/my-site_access_log combined
<IfModule mod_rewrite.c>
#Nginx should have "proxy_set_header HTTPS YES;" in location
RewriteEngine On
RewriteCond %{HTTP:HTTPS} =YES
RewriteRule .* - [E=HTTPS:on,L]
</IfModule>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<DirectoryMatch .*\.svn/.*>
Require all denied
</DirectoryMatch>
<DirectoryMatch .*\.git/.*>
Require all denied
</DirectoryMatch>
<DirectoryMatch .*\.hg/.*>
Require all denied
</DirectoryMatch>
<Directory /home/bitrix/ext_www/my-site.ru>
Options FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
Require all granted
#php_admin_value session.save_path /tmp/php_sessions/ext_www/my-site
php_admin_value upload_tmp_dir /tmp/php_upload/ext_www/my-site
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/managed_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/local_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/stack_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/upload>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/upload/support/not_image>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/images>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/ext_www/my-site.ru/bitrix/tmp>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
</VirtualHost>
Listen 127.0.0.1:8888
<VirtualHost 127.0.0.1:8888>
ServerAdmin webmaster@localhost
DocumentRoot /home/bitrix/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<DirectoryMatch .*\.svn/.*>
Require all denied
</DirectoryMatch>
<DirectoryMatch .*\.git/.*>
Require all denied
</DirectoryMatch>
<DirectoryMatch .*\.hg/.*>
Require all denied
</DirectoryMatch>
<Directory /home/bitrix/www/>
Options FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex index.php index.html index.htm
php_admin_value session.save_path /tmp/php_sessions/www
php_admin_value upload_tmp_dir /tmp/php_upload/www
Require all granted
</Directory>
<Directory /home/bitrix/www/bitrix/cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/www/bitrix/managed_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/www/bitrix/local_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/www/bitrix/stack_cache>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/www/upload>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/www/upload/support/not_image>
AllowOverride none
Require all denied
</Directory>
<Directory /home/bitrix/www/bitrix/images>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
<Directory /home/bitrix/www/bitrix/tmp>
AllowOverride none
AddType text/plain php,php3,php4,php5,php6,phtml,pl,asp,aspx,cgi,dll,exe,ico,shtm,shtml,fcg,fcgi,fpl,asmx,pht
php_value engine off
</Directory>
ErrorLog logs/error_log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
CustomLog logs/access_log combined
<IfModule mod_rewrite.c>
#Nginx should have "proxy_set_header HTTPS YES;" in location
RewriteEngine On
RewriteCond %{HTTP:HTTPS} =YES
RewriteRule .* - [E=HTTPS:on,L]
</IfModule>
</VirtualHost>
Тогда остается подробнее смотреть содержимое
/home/bitrix/ext_www/my-site.ru/.htaccess
Options -Indexes
ErrorDocument 404 /404.php
<IfModule mod_php5.c>
php_flag allow_call_time_pass_reference 1
php_flag session.use_trans_sid off
</IfModule>
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} ^www.my-site.ru
RewriteCond %{REQUEST_URI} !1c_exchange.php
RewriteCond %{REQUEST_URI} !1c_import_xml.php
RewriteRule (.*) https://my-site.ru/$1 [R=301,L]
# Редиректы для адресов без слеша в конце, на адреса со слешем
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [R=301,L]
# Редирект со страниц с **/index.(html|php), на страницы без index.(html|php)
RewriteRule ^index\.(html|php)$ https://%{HTTP_HOST} [R=301,L]
RewriteRule ^(.*)/index\.(html|php)$ https://%{HTTP_HOST}/$1/ [R=301,L]
RewriteRule ^manufacturers/(.*)/(.*)\.(.*)(.*)+$ https://%{HTTP_HOST}/manufacturers/$1/ [R=301,L]
Options +FollowSymLinks
RewriteEngine On
# Редиреты со старых брендовых страниц каталога а GET-запросами, на новые с ЧПУ
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^(en/)?catalog/(.+/)?$ /$0%1/%2/? [R=301,L]
RewriteCond %{QUERY_STRING} ^(trade-company)=([^&]+)$
RewriteRule ^(en/)?catalog/(.+/)?$ /$0%1/%2/? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
RewriteCond %{THE_REQUEST} /(.*)index.php.*$
RewriteCond %{THE_REQUEST} !bitrix/admin/
RewriteRule (.*) https://%{HTTP_HOST}/%1 [R=301,L]
Redirect 301 /favorites/ /order-template/
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpeg "access plus 3 day"
ExpiresByType image/gif "access plus 3 day"
</IfModule>
<Files phpunit>
Order Deny,Allow
Deny from all
</Files>
<Files README.md>
Order Deny,Allow
Deny from all
</Files>
<Files Makefile>
Order Deny,Allow
Deny from all
</Files>
<Files composer.json>
Order Deny,Allow
Deny from all
</Files>
на всех серверах файл идентичен
?
и добавить флаг QSD.RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^(en/)?catalog/(.+/)?$ /$0%1/%2/ [R=301,L,QSD]
Может где-то выше есть ещё .htaccess и RewriteOptions
Ещё вариант попробовать убрать ? и добавить флаг QSD.
RewriteCond %{QUERY_STRING} ^(brand)=([^&]+)$
RewriteRule ^(en/)?catalog/(.+/)?$ /$0%1/%2/ [R=301,L,QSD]
https://my-site.ru/catalog/raskhodnye_materialy/golovki_tortsevye/aksessuary_i_adaptery_dlya_tortsevykh_golovok/perekhodniki_dlya_tortsevykh_golovok/?brand=honito
https://my-site.ru/catalog/?brand=ooo-liteynyy-zavod-samzas-
X-Powered-By: PHP/8.1.22
X-Powered-CMS: Bitrix Site Manager
/catalog/brand/ooo-liteynyy-zavod-samzas-/