I want to add a country code 'en-gb' to an Angular application through htaccess. The folder 'en-gb' does not exist. I only want this to show up in the url & serve index.html
When I hit http://angular.wlocal/ it should change the url to http://angular.wlocal/en-gb & serve index.html from the root folder on the server (without displaying the actual index.html file in the url)
If the requested file/folder does not exist eg. http://angular.wlocal/this-does-not-exist the url should change to http://angular.wlocal/en-gb/this-does-not-exist & serve index.html from the root folder on the server (/index.html)
If a file/folder exists eg. http://angular.wlocal/vendor.js - the url should not change & the file should be served relative to the root folder on the server ( /vendor.js )
This should also apply to directories. eg. http://angular.wlocal/css/style.css should serve /css/style.css on the the server.
My .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#does the folder AND file exist? (ie. /index.html & css/style.css)
#yes - serve it & pop out of htaccess
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
#does the url already have a country flag set?
#no - add country flag (ie. http://angular.wlocal/ -> http://angular.wlocal/en-gb)
RewriteCond %{REQUEST_URI} !/en-gb
RewriteRule ^(.*)$ en-gb/$1
#if file folder not found, serve index.html (ie. http://angular.wlocal/en-gb/this-does-not-exist -> should serve index.html)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
</IfModule>
My Vhosts
<VirtualHost 192.168.56.1:80>
DocumentRoot "C:\Users\Dev\Documents\angular-10\dist"
ServerName angular.wlocal
ServerAlias angular.wlocal
RemoteIPHeader X-Forwarded-For
<Directory "C:\Users\Dev\Documents\angular-10\dist">
DirectoryIndex index.html
AllowOverride ALL
Require all granted
</Directory>
</VirtualHost>
If I remove below, the url changes, But I get The requested URL /en-gb/ was not found on this server.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
Currently, the URL does not change to /en-gb - I think it's because RewriteRule . index.html [L] removes it.
How can I serve index.html from root while preserving this /en-gb rewrite?