Is there a way to link to a resource in a domain-relative but protocol-specific way?
For instance, consider a link on the site http://example.com
...
This links to:
http://example.com/home/ if the page you are on is on the HTTP protocol.
https://example.com/home/ if the page you are on is on the HTTPS protocol.
...
This links to:
http://example.com/home/ always
Is there a way to link to the HTTP version of the site without explicitly stating the full domain?
I found the answer in RFC3986, and the answer supports some of my blind attempts. There is a backwards compatability feature with a previous spec which allows you to specify the scheme if and only if it matches your current scheme. In these cases, if you are linking from http://example.com, the URL http:home will link to http://example.com/home, however https:home will link to https://home/.
Some parsers allow the scheme name to be present in a relative
reference if it is the same as the base URI scheme. This is
considered to be a loophole in prior specifications of partial URI
[RFC1630]. Its use should be avoided but is allowed for backward
compatibility.
"http:g" = "http:g" ; for strict parsers
/ "http://a/b/c/g" ; for backward compatibility
Related
I am using vorto plugin in my Umbraco 7 application to achieve the multilingual capability.
I mentioned the URL in hostname as 'localhost/clientname/en'.
Whenever I open login page the URL which is getting form is 'http://localhost/clientname/en/login'.
This is the structure of vorto URL writing.
But can I achieve it like 'http://localhost/clientname/login/en' ???
I want language names at the end of the URL, not in between.
Is it possible ?
Please help....i am badly stuck in my project task !
It sounds like you need a custom URL provider, setting the domain to 'localhost/clientname/en' will mean that the URLs will always get added AFTER the language part as the host is always the first part of the URL.
Have a look at this article on URL providers and content finders: https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinder/ it's quite old, but it should still work. That should give you an idea of how to make it work. Basically you want the URL provider to append the language to the end of the URL, and the content finder to strip the language from the end and then find the actual content. You can also then set the language of the current thread in the content finder so that Vorto and Umbraco are using the correct language based on the URL.
I would like to use window.external.notify from a webview loading content from the web in a uwp application.
According to documentation
To enable an external web page to fire the ScriptNotify event when calling window.external.notify, you must include the page's Uniform Resource Identifier (URI) in the ApplicationContentUriRules section of the app manifest. (You can do this in Microsoft Visual Studio on the Content URIs tab of the Package.appxmanifest designer.) The URIs in this list must use HTTPS, and may contain subdomain wildcards (for example, https://.microsoft.com) but they cannot contain domain wildcards (for example, https://.com and https://.). The manifest requirement does not apply to content that originates from the app package, uses an ms-local-stream:// URI, or is loaded using NavigateToString.
My question is the following. If I declare the following uri in the manifest
https://www.foo.bar
Does this map to only https://foo.bar or to other uris originating from it like
https://www.foo.bar/foobar
By testing on my side, when adding the domain root Uniform Resource Identifier (URI) to ApplicationContentUriRules, other pages under this folder in the server side could also work well, include the pages on subfolder.
So that to answer your question, ApplicationContentUriRules should be not only work for https://foo.bar, but also other uris originating from it.
If you need also to access pages from sub domains, you need to add subdomain wildcards as the document mentioned.
We have a web project which we are working on (Custom CMS). Have a url example http://www.test.com/page.asp?PID=191
Is there not an way to change this url into something like http://www.test.com/product-title/
Any help would greatly be appreciated.
An old method of doing this was to use custom error handling. Using a 404 custom error handling page you can trap a request to http://www.test.com/product-title/ pull it apart and build the request to the resource in this case http://www.test.com/page.asp?PID=191.
There are various ways of doing this from storing the values in a database so you can lookup your friendly address against it's equivalent to using the URL to describe the resource, something like http://www.test.com/products/191/ then using this as the basis of your rewrite.
In newer versions of IIS though (7 and above) you can use the URL Rewriting to build translation from one URL to another on the fly.
Links
URL Rewrite (download link)
Using the URL Rewrite Module
We can see many HTML page using src="//example.com/myjavascript.js" to include a .js and let the browser use http:// / https:// depending on the current scheme of the page URL.
Is this a valid URI ?
Yes, it is definitely valid. It is a "scheme relative" or "protocol relative" URI. In the spec since the beginning. Quite helpful to deal with http/https issues.
Read a much better description and caveats:
Is it valid to replace http:// with // in a <script src="http://...">?
A few points to keep in mind:
There are some minor issues on IE 7 & 8 with double downloads
If you are viewing an HTML page from a file the browser will replace the scheme with file://, and not load your JS file from the server like it would with a full URL starting with http:// or https://.
Edit for modern webdev practices:
While the URL is still valid, it is now recommended to use https for third party resources (and, serve those resources from secure pages). The performance or compatibility issues from years ago are largely resolved with updated protocols and browsers.
As a warning... we encountered issues with this methodology NOT being supported in Internet Explorer when used inside the HTML BASE tag (IE8 and 9 confirmed, didn't test any others before patching the issue).
After newly implementing SSL on a website, we had initially updated the BASE tags across the application to simply reference "//www.mydomain.com" : but the page templates broke (in IE only) on all scripts which did NOT live at the root of the site. Makes sense, since the BASE tag was not picking up the stylesheet or other relatively-linked resources which assumed they were being referenced from root, not from a nested location.
Since the BASE URI was our own domain anyway, we fixed the issue by setting the BASE tag's value to "https://www.mydomain.com". No matter if the client is browsing the site in SSL mode or out, at least it will work cross-browser now and can ALWAYS find its content - and by forcing https at all times, we ensure we don't get any content-mismatch warnings in the process by setting the BASE path to an http location while browsing a page using https.
It is valid indeed and I have just learned this in the hard way!! We broke a customization feature so you should always validate an URL like this (in .NET):
Pay attention to:
White spaces (Trim)
"scheme relative" URI (UriKind.RelativeOrAbsolute)
public bool IsValidUrl(string resourceUrl)
{
Uri uri;
if (Uri.TryCreate(resourceUrl.Trim(), UriKind.RelativeOrAbsolute, out uri))
{
return uri.IsWellFormedOriginalString();
}
return false;
}
I am using Opencart 1.4.9.4 is there a way that I can change my urls from the query string to category/product?
Example:
Current:
index.php?route=product/category&path=57
Wanted:
domain.co.nz/animals/monkey.php
I have tried google but I have been getting mixed answers with the seo_urls.php and .htacess documents.
1.4.X doesn't have a URL class, so unfortunately not. 1.5.X supports this however
OpenCart does support SEO friendly URLs by default. So you don't have to add a module or modify the code for that.
All you need to do is to locate the file .htaccess.txt under the home folder of your website and rename it to .htaccess and also enable the SEO Friendly URLs option from your admin control panel.
After you've done all that, you can set the "SEO Keyword" for your products by editing them.
Indeed, in recent versions it is supported.
But Be aware of default Opencart SEO friendly URLs.
For example, you can have domain.co.nz/animals/monkey.php urls.
But product monkey belongs to several categories. So you have:
- domain.co.nz/animals/monkey.php
- domain.co.nz/primates/monkey.php
And both links point to the same product page. It will produce duplicates in Google. And products HTML doesn't even contain canonical meta tags.
No so friendly URLs :)