htaccess rewrite urls - how do i write the urls in my code?
Tag : php , By : SpittingCAML
Date : March 29 2020, 07:55 AM
like below fixes the issue If you have server httpd configuration access, You can Place the following code in your server apache server config or place into your httaccess file <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mypage.php [L]
</IfModule>
$Get_data = explode('/', $_SERVER[REQUEST_URI]);
$_GET['var'] = $Get_data[1];
$_GET['var2'] = $Get_data[2];
|
Converting JSON urls to regular urls from an ajax call
Date : March 29 2020, 07:55 AM
Hope that helps If you don't want to lock down yourself with .json hard-coded extension, you can get the lastIndexOf of . & get the substring from 0. I guess this will do the trick! var url = data.url;
console.log(url.substring(0, url.lastIndexOf('.')));
|
How too re-write some long urls to shprter urls
Date : March 29 2020, 07:55 AM
Any of those help You should replace the second (.*) by $1 (The content of the first capturing parenthesis).
|
Date : March 29 2020, 07:55 AM
like below fixes the issue it seems you forgot to add one more header "accept": "application/vnd.twitchtv.v5+json" var settings = {
"async": true,
"crossDomain": true,
"url": "https://api.twitch.tv/kraken/channels/44322889",
"method": "GET",
"headers": {
"client-id": "k7uj51l1cteh0sbhwplk4hqq6c7bqo",
"accept": "application/vnd.twitchtv.v5+json"
}
}
$.ajax(settings).done(function (response) {
console.log(response);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
How do i write a function that detects and replaces urls in a loaded JSON?
Tag : json , By : Santhanam
Date : March 29 2020, 07:55 AM
will help you You can create a pipe to transform the loadedJSON like below and [innerHTML] property binding import { PipeTransform, Pipe } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
@Pipe({
name: "transformURL",
pure: false
})
export class TransformURLPipe implements PipeTransform {
constructor(protected sanitizer: DomSanitizer) { }
transform(value: any): any {
if (value.length === 0) {
return value;
}
return this.sanitizer.bypassSecurityTrustHtml(
value.replace(/url:\/\//g, "<button type='button'>Test</button>")
);
}
}
<p [innerHTML]=" loadedJSON | transformURL"></p>
|