我想将样式请求从子域重定向到主域
https://dir.example.com/assets/(.*)
至https://example.com/assets/(.*)
我可以通过以下代码通过子文件夹成功管理此问题:
example.com/dir/assets/(.*)
至example.com/assets/(.*)
RedirectMatch 301 ^/dir/assets/(.*)$ /assets/$1
我尝试修改子域,但是以下代码不起作用:
RedirectMatch 301 ^dir.example.com/assets/(.*)$ example.com/assets/$1
从子域到主域重写资产的正确方法是什么?
答案 0 :(得分:1)
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>