S
S
stichii2016-11-07 16:29:47
htaccess
stichii, 2016-11-07 16:29:47

How to exclude pages from a redirect?

Good afternoon! you need to set up a redirect for all pages of the old site (site-old.ru) to a new page of the new site (site.ru/page1/). There were no problems with everything set up

RewriteEngine on
RewriteCond %{HTTP_HOST} ^site-old.ru$ [OR]
RewriteCond %{HTTP_HOST} ^www.site-old.ru$
RewriteRule ^(.*)$ http://site.ru/page1/ [L,R=301]

But now we need to add an exception for some pages of the old site. So that redirects do not work for certain pages of the old site.
There is a question + answer on the toaster How to add an exception to a redirect rule in htaccess?
I do the same.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^site-old.ru$ [OR]
RewriteCond %{HTTP_HOST} ^www.site-old.ru$
RewriteCond %{REQUEST_URI} ^!kontaktyi/$
RewriteRule ^(.*)$ http://site.ru/page1/ [L,R=301]

But then the redirect stops working altogether. Can you tell me what is wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Yanchevsky, 2016-11-07
@deniscopro

Kind.
Try this
You will probably also need file exclusions

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

Pulled from a working project, maybe it will help
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_URI} !^/index.php$
RewriteCond %{REQUEST_URI} !^/en$
RewriteCond %{REQUEST_URI} !^/en/$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://site.com/$1 [L,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question