S
S
Svah2018-02-12 23:02:20
htaccess
Svah, 2018-02-12 23:02:20

How to redirect by multiple filters using .htaccess?

Now a redirect is configured from any page to the main
.htaccess

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
RewriteRule ^$index.html
RewriteRule ^([^.]+)$index.html

The task is to redirect any address, except for certain paths (folders)
For example, you do not need to redirect folders, namely open files at addresses:
domain/ img /*
domain/ video /*
But redirect all other variations to the main
domain/*
In other words : I would like to add exceptions to the current version, where the redirect rule would not work on the main page.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor Taran, 2018-02-13
@Svah

RewriteCond %{REQUEST_URI} !^domain/img/.*$
RewriteCond %{REQUEST_URI} !^domain/video/.*$
RewriteCond %{REQUEST_URI}  .....
RewriteCond %{REQUEST_URI}  и так далее, это  и если, и будет копиться условия до первого рула, ! - знак отрицания.
RewriteRule  а тут что должно произойти

M
mafia8, 2018-02-13
@mafia8

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
RewriteRule ^(.*)$ http://%1/$1 [ R=301,L]
RewriteRule ^$index.html
RewriteRule ^([^.]+)$index.html
To display folders and files as usual.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question