V
V
Vlad2019-02-14 23:14:59
htaccess
Vlad, 2019-02-14 23:14:59

How to write a redirect exception in htaccess?

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule !(^$|.*\.(css|jpg|gif|ico)) / [R=301,L]

How can I make this redirect work on all pages except index2.html ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-02-14
@Sc0undRel

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_URI} !^/index2\.html
RewriteRule !(^$|.*\.(css|jpg|gif|ico)) / [R=301,L]

Or like this:
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule !^($|index2\.html|.*\.(css|jpg|gif|ico)) / [R=301,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question