I have uploaded my website under a sub-directory on my server the structure is looks something like this
root
----blog
--------.htaccess
----apple
----.htaccess
Now I have written a rule inside my /blog/.htaccess file which will redirect users to
I have done this by adding the following rule.
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} !on
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [R=301,L,NE]
so far so good it is working exactly like the requirements, Now the real issue come. User wants that when ever any one hit the domain without the preceding blog it will add the /blog/ and redirects the user to the blog site and this rule should not effect any sub-domain means if
User enters the url.
example.com
He should be redirected to.
And when he enters url.
apple.example.com
He should redirected to
apple.example.com
Now In order to do so I am writing the following rule but it is not working the rule looks like this.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*) https://example.com/$1 [R=301,L]
RewriteRule ^$ /blog/ [L]
I don't know what I am doing wrong.
I have added so much detail because I thought may be the .htaccess file inside the blog directory is making an issue.