Answer the question
In order to leave comments, you need to log in
How to write an htaccess rule?
Please tell me how to make a regular expression for my site.
Need a redirect.
from domain.ru/page1/1 to domain.ru/page1
from domain.ru/page1/2 to domain.ru/page1
from domain.ru/page1/25 to domain.ru/page1
from domain.ru/page1/25 /123 to domain.ru/page1
from domain.ru/page1/55/123 to domain.ru/page1
and so on... (all these pages are generated by WordPress on their own)
Answer the question
In order to leave comments, you need to log in
Redirect from old static (cnc) page to new page:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.ваш_сайт\.ru$ [NC]
RewriteRule ^старая_страница $ новая_страница [R=301,L]
Redirect 301 /page1/1 domain.ru/page1
Redirect 301 /page1/2 domain.ru/page1
Redirect 301 /page1/25 domain.ru/page1
Redirect 301 /page1/25/23 domain.ru/page1
add_action( 'template_redirect', function() {
if ( preg_match( '#^/subscribe/?$#i', $_SERVER['REQUEST_URI'] ) ) {
wp_redirect( 'http://example.org/path/to/subscribe', 301 );
exit;
}
} );
RewriteEngine On
RewriteBase /
## Два выражения выше уже должны быть в идеале ##
RewriteCond %{REQUEST_URI} ^(.*)(\/page1\/)(\S+)$
RewriteRule ^(.*)$ %2 [R=301,L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question