Sounds like the recommended way to do it is to have your server read the Origin header from the client, compare that to the list of domains you would like to allow, and if it matches, echo the value of the Origin
header back to the client as the Access-Control-Allow-Origin
header in the response.
With .htaccess
you can do it like this:
# ---------------------------------------------------------------------- # Allow loading of external fonts # ---------------------------------------------------------------------- <FilesMatch "\.(ttf|otf|eot|woff|woff2)$"> <IfModule mod_headers.c> SetEnvIf Origin "http(s)?://(www\.)?(google.com|staging.google.com|development.google.com|otherdomain.example|dev02.otherdomain.example)$" AccessControlAllowOrigin=$0 Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin Header merge Vary Origin </IfModule> </FilesMatch>
Related Posts:
- How does Access-Control-Allow-Origin header work?
- How to redirect all HTTP requests to HTTPS
- How to remove .html from URL?
- How to remove .html from URL?
- Change PHP version on server using either .htaccess or php.ini
- Response to preflight request doesn’t pass access control check
- Origin null is not allowed by Access-Control-Allow-Origin
- wordpress image upload error and htaccess rule explanation
- .htaccess Remove WWW from URL + Directories
- CodeIgniter removing index.php from url
- .htaccess deny from all
- Server unable to read htaccess file, denying access to be safe
- Https to http redirect using htaccess
- “Cross origin requests are only supported for HTTP.” error when loading a local file
- “Cross origin requests are only supported for HTTP.” error when loading a local file
- How to enable CORS in AngularJs
- Why does my http://localhost CORS origin not work?
- Redirect non-www to www in .htaccess
- Generic htaccess redirect www to non-www
- Using Errordocument 401 leads to blank page
- Redirect www to non-www htaccess
- Redirect from https to http or from http to https? [closed]
- Redirect http to https does not work on subdir where another instance of WordPress installed
- 403 error on admin login page
- How to use https on one page only?
- Strange behavior: random HTTP error 500 fixed by visiting Permalinks settings page (htaccess issue with language code)
- Understanding Redirects
- Redirect HTTP request to HTTPS request
- throttle/limit a logged in user’s http requests to specific page on a per day basis
- Should a 502 HTTP status code be used if a proxy receives no response at all?
- Why does my JavaScript code receive a “No ‘Access-Control-Allow-Origin’ header is present on the requested resource” error, while Postman does not?
- HTTP Status 504
- How to define the basic HTTP authentication using cURL correctly?
- What’s the difference between “Request Payload” vs “Form Data” as seen in Chrome dev tools Network tab
- How to send HTTP request in java? [duplicate]
- wget: unable to resolve host address `http’
- .htaccess: Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration
- How to add custom rewrite rule to .htaccess?
- File and directory permissions
- WP-Admin not working properly at WordPress multisite with subdirectories
- Passing variables through permalink structure
- Remove subfolders from URL
- Isolating WordPress to a subfolder
- htaccess or redirect to cloak portion of a link?
- Suppress subdirectory from WordPress Multisite primary URL
- WordPress – https : Css and Js files are not working (load on http instead of https)
- Why wordpress multisite redirect to wp-signup if site exists?
- What is the role of .htaccess file in WordPress?
- Should I add the IP of the server that hosts my sites to the list of authorized IPs in the wp-admin/.htaccess?
- Block only external access to wp-cron.php on OpenLiteSpeed
- Which HTTP headers to use for subdomain embedding?
- using wp_remote_get to retrieve own url on local host
- Divert http to https with WordPress on IIS
- htaccess 301 redirect http to https doesn’t work
- WordPress On subfolder
- Use htaccess to redirect WordPress to static website in a subfolder
- Create rewriterules for different domains in htaccess file with WP multisite
- Changes to .htaccess not updating the file (old rules still take effect)
- POST request not going through?
- How to redirect URL with subfolder to the same URL but without subfolder?
- HTTP sitewide, except for: wp-admin, and 2 custom directories
- How do I host WordPress on a hidden domain through a reverse proxy?
- WordPress installed in root, need second in subdirectory with different domain
- htaccess has broken my site
- SSL and www to non-www redirection works only on homepage – WordPress
- Cannot access wp-admin without trailing slash – .htaccess configuration for WordPress behind a nginx proxy
- Wildcard forward all posts and pages with few exceptions
- Htaccess file isn’t redirecting http sub-pages to https––they display 404 error instead, tried many solutions and none work
- How to change redirection route to a php page for making it only accessible by logged-in members?
- WordPress keeps redirecting subpages without http to https homepage after switch
- Create a multisite network for an existing installation
- WordPress changing script source from https to http
- ReDirect subfolder link to another sub-folder and force SSL
- Cannot use Network Admin (Dashboard) on Multi-site after 301 www redirect
- Remove .htaccess portion upon plugin deactivation?
- Will deleting WP’s code in .htaccess cause problems?
- .htpasswd asking for authentication on home page
- WordPress login fail after .htaccess domain redirect
- Access sub-domain when root public_html is protected with .htaccess password
- Redirect https://www.subdomain.domain.com is not redirecting to subdomain.website.com [closed]
- How can I leverage browser cache for minified JS or minified CS files?
- Deny access to uploads folder with exceptions
- Proper way to set up rewrite with Wp
- hide theme files for admin beneath root
- Specific Page/Post Need to Stay Non SSL
- Should I prevent access to .htaccess and wp-config.php files?
- WordPress not linking correctly with .htaccess redirect to subdirectory
- Multisite htaccess with domain rewrites
- Clicking PUBLISH Now Redirects to 404 PAGE NOT FOUND
- .htaccess not working after page slug change
- 301 redirect from webpage to wordpress page in the same root
- Rewrite /keyword1+keyword2.html to search page | .htaccess
- Need to edit htaccess while moving on WordPress
- How can I create a private site that is inaccessible from the outside?
- Permalinks in Multisite not working
- Detect if request is coming from wordpress conditional statement
- Using the wp_remote_post response body
- Can I redirect the http request towards an old folder to the homepage using .htaccess file? [closed]
- WordPress redirection
- How to rewrite URL using .htaccess in WordPress Plugin