Reputation: 41
I want to redirect styles requests from subdomain to main domain
https://dir.example.com/assets/(.*)
to https://example.com/assets/(.*)
I am able to successful manage this issue with subfolder via bellow code:
example.com/dir/assets/(.*)
to example.com/assets/(.*)
RedirectMatch 301 ^/dir/assets/(.*)$ /assets/$1
I tried to modify for subdomain but bellow code is not working:
RedirectMatch 301 ^dir.example.com/assets/(.*)$ example.com/assets/$1
what will be correct way of rewriting assets from sub-domain to main domain ?
Upvotes: 0
Views: 54
Reputation: 41
I did it:
RewriteCond %{HTTP_HOST} ^(.*)\.example\.org[NC]
RewriteRule ^/?assets/(.*)$ https://example.org/crm/assets/$1 [L,R]
but now i have bigger issue:
Access to font at 'https://example.org/crm/assets/plugins/roboto/fonts/Regular/Roboto-Regular.ttf?v=1.1.0' from origin 'https://crm1.example.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Found Solution for second issue
.htaccess
<FilesMatch "\.(ttf|otf|eot|woff|woff2)$">
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
</FilesMatch>
Upvotes: 1