K
K
kalkoolesya2020-02-01 23:10:45
htaccess
kalkoolesya, 2020-02-01 23:10:45

How to set up an exception for a redirect from a domain to a subdomain?

I use a redirect on the site from a domain to a subdomain:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} robots.txt$ [NC]
RewriteRule ^([^/]+) $1 [L]
RewriteRule (.*) https://1.domain.com/$1 [R=302,L]

But it is necessary to make an exception for the sitemap.xml file, in general it is important that it opens at domain.com/sitemap.xml, how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-02-01
@kalkoolesya

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/robots\.txt$
RewriteCond %{REQUEST_URI} !^/sitemap\.xml$
RewriteRule (.*) https://1.domain.com/$1 [R=302,L]

Or
RewriteEngine On

RewriteRule ^(robots\.txt|sitemap\.xml)$ - [L]

RewriteRule (.*) https://1.domain.com/$1 [R=302,L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question