Is $_SERVER[‘REQUEST_SCHEME’] reliable?

The REQUEST_SCHEME environment variable is documented on the Apache mod_rewrite page. However, it didn’t become available until Apache 2.4. I only have Apache 2.2 so I created an environment variable. I added the following to the top of my .htaccess file. RewriteEngine on # Set REQUEST_SCHEME (standard environment variable in Apache 2.4) RewriteCond %{HTTPS} off … Read more

Creating a new Location object in javascript

Well, you could use an anchor element to extract the url parts, for example: var url = document.createElement(‘a’); url.href = “http://www.example.com/some/path?name=value#anchor”; var protocol = url.protocol; var hash = url.hash; alert(‘protocol: ‘ + protocol); alert(‘hash: ‘ + hash); ​ It works on all modern browsers and even on IE 5.5+. Check an example here.

Change URL parameters and specify defaults using JavaScript

I’ve extended Sujoy’s code to make up a function. /** * http://stackoverflow.com/a/10997390/11236 */ function updateURLParameter(url, param, paramVal){ var newAdditionalURL = “”; var tempArray = url.split(“?”); var baseURL = tempArray[0]; var additionalURL = tempArray[1]; var temp = “”; if (additionalURL) { tempArray = additionalURL.split(“&”); for (var i=0; i<tempArray.length; i++){ if(tempArray[i].split(‘=’)[0] != param){ newAdditionalURL += temp + … Read more

How to convert URL parameters to a JavaScript object? [duplicate]

In the year 2021… Please consider this obsolete. Edit This edit improves and explains the answer based on the comments. var search = location.search.substring(1); JSON.parse(‘{“‘ + decodeURI(search).replace(/”/g, ‘\\”‘).replace(/&/g, ‘”,”‘).replace(/=/g,'”:”‘) + ‘”}’) Example Parse abc=foo&def=%5Basf%5D&xyz=5 in five steps: decodeURI: abc=foo&def=[asf]&xyz=5 Escape quotes: same, as there are no quotes Replace &: abc=foo”,”def=[asf]”,”xyz=5 Replace =: abc”:”foo”,”def”:”[asf]”,”xyz”:”5 Suround with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)