M
M
Makssof2019-05-18 19:07:28
Apache HTTP Server
Makssof, 2019-05-18 19:07:28

How to properly link RewriteCond?

Actually, subject.
You need to redirect domain.com/bar/.. to the main one, only if not foo.domain.com/bar/..
Tried like this:

RewriteCond %{HTTP_HOST} !^([.]+)\.domain.com$ [NC]
RewriteCond %{REQUEST_URI} ^/bar [NC]
RewriteRule ^(.*)$ https://domain.com [L,R=302]

Redirects to home page even from foo.domain.com/bar/..
Tried:
RewriteCond %{HTTP_HOST}%{REQUEST_URI} ^domain.com/foo
RewriteRule ^(.*)$ https://domain.com [L,R=302]

Doesn't give anything at all. Even mistakes.
It already seems to me that this is impossible to implement. Or I'm wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-05-18
@makssof

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^bar/ https://domain.com/ [L,R=302]

Or
RewriteCond %{HTTP_HOST} !^foo\.domain\.com$ [NC]
RewriteRule ^bar/ https://domain.com/ [L,R=302]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question