Насколько помню в WinAPI для перемещения окон есть MoveWindow.
Для её использования нужно знать дескриптор окна.
Если не знаешь класс окна и заголовок окна меняется, то FindWindow не подойдёт.
Можно пройтись по всем окнам верхнего уровня с помощью EnumWindows.
Читать заголовки окон с помощью GetWindowText и сравнивать их с шаблоном.
RewriteCond %{QUERY_STRING} =opt=commentsRewriteRule ^(.*)$ http://site.ru/$1?opt=discussion [R=301,L]
Для /papka/index.html => /papka
RewriteCond %{THE_REQUEST} "^\S+ /(.+)/index\.html HTTP/"RewriteRule ^ http://site.ru/%1 [R=301,L]
Или
RewriteRule ^(.+)/index\.html$ http://site.ru/$1 [R=301,L]
Правила применяются последовательно.
Первым правилом отправляем главную на /dir/.
Во второе правило попадёт всё остальное.
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.ru$ RewriteRule ^$ http://www.site2.ru/dir/ [R=301,L] RewriteCond %{HTTP_HOST} ^(www\.)?site1\.ru$ RewriteRule ^(.*)$ http://www.site2.ru/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?otkuda$ RewriteRule ^katalog/\d+ http://kuda/$0 [R=301,L]
Возможно, редиректы стоят не первыми и над ними есть правила, которые что-то меняют в параметрах.
А можно увидеть содержимое .htaccess полностью?
/ru/forum/comment/14306171
# с www на без-www #Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.site\.ru RewriteRule ^(.*)$ http://site.ru/$1 [R=permanent,L] #index.php на / #RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ #RewriteRule ^index\.php$ http://site.ru/ [R=301,L] #index.html на / #RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ #RewriteRule ^index\.html$ http://site.ru/ [R=301,L] ##### Start ?tp=1 prevention Запретить просмотр позиций модулей ###### RewriteCond %{QUERY_STRING} tp=(.*) RewriteRule ^(.*)$ index.php [F,L] ##### End ?tp=1 prevention ###### ## # @package Joomla # @copyright Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved. # @license GNU General Public License version 2 or later; see LICENSE.txt ## ## # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE! # # The line just below this section: 'Options +FollowSymLinks' may cause problems # with some server configurations. It is required for use of mod_rewrite, but may already # be set by your server administrator in a way that dissallows changing it in # your .htaccess file. If using it causes your server to error out, comment it out (add # to # beginning of line), reload your site in your browser and test your SEF url's. If they work, # it has been set by your server administrator and you do not need it set here. ## ## Can be commented out if causes errors, see notes above. Options +SymLinksIfOwnerMatch ## Mod_rewrite in use. ## Begin - Rewrite rules to block out some common exploits. # If you experience problems on your site block out the operations listed below # This attempts to block the most common type of exploit `attempts` to Joomla! # # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR] # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F] # ## End - Rewrite rules to block out some common exploits. ## Begin - Custom redirects # # If you need to redirect some pages, or set a canonical non-www to # www redirect (or vice versa), place that code here. Ensure those # redirects use the correct RewriteRule syntax and the [R=301,L] flags. # ## End - Custom redirects ## # Uncomment following line if your webserver's URL # is not directly related to physical file paths. # Update Your Joomla! Directory (just / for root). ## # RewriteBase / ## Begin - Joomla! core SEF Section. # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # # If the requested path and file is not /index.php and the request # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} !^/index\.php # and the request is for something within the component folder, # or for the site root, or for an extensionless URL, or the # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC] # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d # internally rewrite the request to the index.php script RewriteRule .* index.php [L] # ## End - Joomla! core SEF Section.
Правила применяются одно за другим в то том порядке, в котором записаны.
RewriteRule ^(.*)$ /index.php [L] RewriteCond %{HTTP_HOST} ^site\.ru$ [NC] RewriteRule ^(.*)$ http://www.site.ru/$1 [R=301,L]
Первое правило отвечает за ЧПУ и направляет все запросы на /index.php
Второе правило делает редирект на www, но так как первое правило уже поменяло адрес, то редирект всегда будет на адрес www.site.ru/index.php
Правила для редиректа должны срабатывать первыми, т.е. до того как правила для ЧПУ что-нибудь поменяют.
RewriteCond %{HTTP_HOST} ^site\.ru$ [NC] RewriteRule ^(.*)$ http://www.site.ru/$1 [R=301,L] RewriteRule ^(.*)$ /index.php [L]
Ещё вариант
RewriteCond %{THE_REQUEST} " /news/ " RewriteRule ^ news.php [L]
%{THE_REQUEST} содержит полную строку запроса
GET /news/ HTTP/1.1
RewriteEngine On RewriteCond %{THE_REQUEST} " /cattest\.php(?:\?(test\d+))? " RewriteRule ^ /catalog/%1? [R=301,L]
Если простой случай, когда между словом и тегом нет пробелов и других слов <h2>слово</h2>
$text = preg_replace('/(?<!\p{L}|<h2>)'.preg_quote($value['faq_menu'], '/').'(?!\p{L}|<\/h2>)/ui', '<a href="/faq/'.$value['faq_url'].'/">\0</a>', $text);
Если посложнее <h2>лала слово блабла</h2>
/\G(?:<h2>.*?<\/h2>|\Kслово(*ACCEPT)|.)++(?!)/uis https://regex101.com/r/mE1aV1/1
$text = preg_replace('/\G(?:<h2>.*?<\/h2>|\K(?<!\p{L})'.preg_quote($value['faq_menu'], '/').'(?!\p{L})(*ACCEPT)|.)++(?!)/uis', '<a href="/faq/'.$value['faq_url'].'/">\0</a>', $text);
Ну раз \b не работает с кириллицей в UTF-8, то можно попробовать через cвойства unicode-символов.
/(?<!\p{L})слово(?!\p{L})/u
Шаблон проверяет, что вокруг слова нет других букв.
$text = 'лалаланужное_словолалала нужное_слово лалала'; $replace = 'нужное_слово'; $url = 'anyurl.html'; $text = preg_replace('/(?<!\p{L})'.preg_quote($replace, '/').'(?!\p{L})/ui', '<a href="'.$url.'">'.$replace.'</a>', $text); echo $text;