Suppose My domain is
I have created a sub domain
I wanted to always open my both site (main + subdomain) with www prefix
for that I place the below code to .htaccess
RewriteCond %{HTTP_HOST} !^www\.
#RewriteCond %{HTTP_HOST} !^dev\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
Main site working fine its redirect domain.com to https://www.example.com
But dev.example.com redirects to https://www.dev.example.com/development and cause 500 Internal Server Error. It should be redirected to https://www.dev.example.com instead of https://www.dev.example.com/development
Where I am going wrong.
I tried different Codes in .htaccess but nothiing works.
Converting my comment into an answer to that it might help someone facing similar problem.
Move above rule in development/.htaccess
so that per directory directive RewriteRule
sets $1
value relative to development
directory instead of public_html
directory.
Make sure to test it after clearing browser cache.