PHP CORS Cross Origin access control allow origin example html
CORS-Cross-Origin-Resource-Sharing Header set Access-Control-Allow-Origin Source Code Example
Usefull Links here
https://www.w3.org/wiki/CORS_EnabledApache .htaccess Allow File Types
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
<FilesMatch ".(bmp|cur|gif|ico|jpe?g|png|svgz?|webp)$">
SetEnvIf Origin ":" IS_CORS
Header set Access-Control-Allow-Origin "*" env=IS_CORS
</FilesMatch>
</IfModule>
</IfModule>
.htaccess which is closest to the file!!!!!
Date: 17.06.2020 - 08:0977LW NO topic_id
AD
Další témata ....(Topics)
Pokud chceme vytvořit soubor, jehož obsah bude čten, jako UTF-8 UNICODE stačí vstupní string nechat projít funkcí utf8_encode.
Pokud pak například text souboru použijeme v php scriptu v kódování UTF-8, text souboru bude správně zobrazen.
$fHnd = fopen($newName, "w");
$row = utf8_encode('řčšě');
fwrite($fHnd, $row."\r\ n");
fclose($fHnd);
Jak zjistit v javascriptu zda objekt existuje
How test if an object exists undefined or null.
if (typeof OBJECT_NAME != "undefined") {
//object exists ... execute code here.
}
// or best of use try catch
var nObject;
try{
nObject = image.image; // is image.image object?
}catch (e){
alert(e.message.toString()); // e.message == 'undefined' is null or not an object
return; // or continue if image.image is a object
}
// you can test now nObject as typeof nObject
if(typeof nObject == 'string') // or others etc.
{
// do something
}
// dont use this
if (OBJECT_NAME != null) {
//if object dont exists will error
}
Příklad vychází z předpokladu, že těsně před konečným
tagem /BODY je kontejner tag s názvem < footer>< /footer>.
Mezeru < TAGNAME nutno odstranit v reálném kódu.
Pokud tento tag je nalezen, lze předpokládat, že uživatel
stránku již uvidí celou, protože většina prohlížečů si s
tím poradí a doplní chybějící uzavírací tagy BODY a HTML.
// < TAGNAME remove space after < !!!!!
< BODY onload="myFunction">
< sript>
function myFunction() {
var x = document.getElementsByTagName ("footer");
if(x.length === 0)
alert("Page not loaded correctly ... not find tag footer x" + x);
else
alert("Heureka! :) FOOTER is loaded!");
}
< /script>
Jak snadno vložit na stránku přenositelný kód s copyright vašich stránek v php.
<font color=#3E845E size="0.8px">Copyright © 2008-<?php print date("Y").' '.$_SERVER ["HTTP_HOST"];?>, all right reserved
</font><br>
HTTP to HTTPS
# only one RewriteEngine On can be used in htaccess!!!!!!!!!!!!!!
RewriteEngine On
# all redirection HTTP -> HTTPS
# HTTPS off / if start with http.....
# off equality !=on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
example.com to www.example.com
# redirection no www -> https://www.
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
Change sitemap.txt to sitemap.php if url //domain.com/sitemap.txt
# //domain.com/sitemap.txt open sitemap.php
# in sitemap.php is function what return list of address
RewriteRule ^sitemap\.txt$ sitemap.php [L]
RewriteRule ^sitemap$ sitemap.php [L]
Remove www. before subdomain name
www.subdomain.example.comto
subdomain.example.com
RewriteCond %{HTTP_HOST} (^|\.)(www\.)([^\.]*)\.example\.com$ [NC]
RewriteRule (.*) https://%3.example.com/$1 [R=301,QSA,L]
Remove dust before subdomain.example.com
# www.bla.www.m.bla.subdomain.example.com to subdomain.example.com
RewriteCond %{HTTP_HOST} (.*)(subdomain.example.com$) [NC]
RewriteRule (.*) https://subdomain.example.com/$1 [R=301,QSA,L]
Remove only one www. before domain name
# redirection www. -> https://
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
Editace: 17.6.2020 - 12:56
Počet článků v kategorii: 77
Url:php-cors-cross-origin-access-control-allow-origin-example-html