Redirect Non WWW to WWW - htaccess placed in sub-folder

0

I am working on a site which has .htaccess file in root. There is a folder named babynames. This folder also has .htaccess file. I need the code to redirect from NON WWW to WWW for this folder. Anybody comes to this folder without www should be redirected to www.

The code at /babynames/.htaccess is


RewriteEngine On RewriteBase /babynames/

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.astrolika.com/babynames/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /babynames/404.php/$1 [L,QSA]


ErrorDocument 404 /babynames/404.php

DirectoryIndex index.php

Can anybody guide me to resolve this issue.

amita734

Posted 2018-12-08T11:02:54.810

Reputation: 1

What issue, precisely? – user1686 – 2018-12-08T11:43:58.830

If i use https without www it does not redirected to www for folder babynames – amita734 – 2018-12-08T13:27:52.390

Answers

0

From the post Use htaccess to add www with https support:

RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

The second condition checks if the HTTPS environment variable (either on or off) is set to on and captures the appended s that is then available with %1. If it doesn’t match, %1 is just an empty string.

harrymc

Posted 2018-12-08T11:02:54.810

Reputation: 306 093