Pak Jiddat - Innovative Software Services

Read: In the name of thy Lord Who createth, Createth man from a clot. Read: And thy Lord is the Most Bounteous, Who teacheth by the pen, Teacheth man that which he knew not. Nay, but verily man is rebellious That he thinketh himself independent!. Lo! unto thy Lord is the return. (Sura Alalaq 96:8)

Allowing Cross Origin Requests using htaccess

Created On: 29 Mar, 2017: 17:04:32 - Tags : javascript | web servers


htaccess directives can be used to allow requests from different domains. For example the following directives added to htaccess file should allow access from any domains:

Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

Related Articles

  1. Redirect http to https with Apache
  2. Creating and Installing Apache Self Signed Certificate
  3. Using flags with rewrite rule
  4. Redirecting without mod_rewrite using regular expressions in htaccess
  5. Generate Certificate Signing Request (CSR) for ssl certificates
  6. Disabling output buffering with mod_fcgid
  7. Configuring Apache mod status
  8. Redirect http to https with Nginx
  9. Access control directives for Apache
  10. Blocking visitors by http method using LimitExcept Apache directive
  11. Passing query parameters to proxy server in Nginx
  12. Use of Preflight request in HTTP Cross Origin Resourse Sharing (CORS)
  13. Using RewriteCond directives
  14. Adding event listeners using JavaScript
  15. Using Prefetch, Preload and Preconnect for speeding page load times
  16. Get current unix timestamp using Javascript
  17. Fetching parent node element of a HTML node
  18. Adding option to html selectbox using Javascript
  19. Changing CSS styles using Javascript
  20. Fetching html elements using CSS class names
  21. Fetching html elements using CSS selectors with Javascript
  22. NodeJs permission denied error
  23. Customizing Redmine layout
  24. Passing parameters to Jquery event handler function
  25. W3C.Data
  26. Making cross domain Ajax calls using JSONP
  27. Get the time using JavaScript
  28. Convert javascript object to json string
  29. Using cookies in Javascript
  30. Javascript JSON guide
  31. Javascript date object
  32. Get co-ordinates of element relative to document using Jquery
  33. Base64 Encoding of utf-8 encoded string using Javascript
  34. Using clearTimeout and onmouseenter, onemouseleave events
  35. Setting CSS styles using JQuery
  36. Replacing html element using replaceWith jquery function
  37. Using keydown event handler for detecting enter key press
  38. Replacing a string using Javascript replace function
  39. Iterate throught Javascript object properties
  40. Select contents on text field