3

I have an .htaccess in root directory to redirect to a subdomain.

RewriteEngine on
RewriteCond %{HTTP:Accept-Language} (en) [NC]
RewriteRule .* https://en.domain.com [R,L]

In the same directory I also have my assets folder though and since is inheriting the .htaccess I'm not able to access files inside it. Is there a way to give authorization to access subdirectories?

RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93
dnlgrs
  • 93
  • 5
  • Thanks for showing your efforts, could you please post samples of URLs which you want to have access and which you don't want to? It will provide us better understanding of your question, thank you. – RavinderSingh13 Jan 22 '21 at 12:14
  • So if www.domain.com is inserted I want to go to en.domain.com and that's working. I'd like to access my assets folder with domain.com/assets/ inside I have images, css, js but that's not working because I get redirected to en.domain.com since the assets folder in inerhiting .htaccess from directory folder. Thanks for the fast reply – dnlgrs Jan 22 '21 at 12:20

1 Answers1

2

How about adding one more condition to your Rules and try it once. This will only redirect only base url eg--> www.domain.com to new url.

RewriteEngine ON
RewriteCond %{REQUEST_URI} ^/?$
RewriteCond %{HTTP:Accept-Language} (en) [NC]
RewriteRule ^ https://en.domain.com [R=301,L]
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93