Is it permissible to write in the href attribute of the base tag the URL of a directory (for example, http://domain.com/path/ ) and not the final document? The fact is that it is very convenient to form relative references to images, scripts, etc.
The problem is as follows. I am developing a CMS for PHP. With mod_rewrite all requests of the form http://domain.com/path/artist/edit/25 are converted to the form http://domain.com/path/index.php?url=/artist/edit/25 . Thus, the part of the URL after http://domain.com/path/ is virtual.
For convenience and to improve CMS performance, I use HTML in the form of <a href="artist/show">...</a> links and links to resources (images, scripts, etc.) in <link href="ui/css/style.css"...> format <link href="ui/css/style.css"...> .
It all works using an HTML construct that is the same for any URL of the final material:
... <base href="http://domain.com/path/" /> ... CSS and scripts are addressed as follows:
... <!-- Custom page style CSS --> <link href="ui/css/style.css" rel="stylesheet" type='text/css'> <!-- Support for CSS3 media query in IE8 --> <script type="text/javascript" src="ui/js/respond.js"></script> <!-- MooTools 1.6.0 --> <script type="text/javascript" src="ui/js/MooTools-Core-1.6.0.js"></script> ... Trying to get a deeper understanding of the topic, I found several articles and the site https://developer.mozilla.org/ru/docs/Web/HTML/Element/base where it is indicated that <base href=...> should contain the URL of the current document. If this is true, then the whole original idea collapses.
After looking at the HTML code of popular and medium-sized sites, we managed to find out that about half prefer not to use relative links at all, 10% -15% do the same as I do, the rest use relative addressing from the domain name (use links like /css/style.css ).
Hence a number of related questions:
- How common is the practice when
<base href=...>points to a directory, not a final document? - Does this practice comply with the approved standard?
- If
<base href=...>does not indicate the URL of the final document, are there any problems with the site being indexed by search robots?
Also, in the comments, I would like to hear opinions on how to simplify the format of links to resources.