G
G
German Jet2016-10-17 11:54:22
Apache HTTP Server
German Jet, 2016-10-17 11:54:22

How to add exception to redirect rule in htaccess?

This is how I redirect all requests to oldsite to newsite:

Options +FollowSymLinks
RewriteEngine on

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

How to make sure that the URL oldsite.ru/camera/$ is not redirected to newsite?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2016-10-17
@GeraJet

I think it's obvious, use negation!

RewriteCond %{HTTP_HOST} ^oldsite\.ru
RewriteCond %{REQUEST_URI} ^!camera/$
RewriteRule ^(.*)$ http://newsite.ru/$1 [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question