Amphtml: Allow the <base> tag

Created on 25 Feb 2016  Â·  9Comments  Â·  Source: ampproject/amphtml

The tag is currently disallowed, albeit @cramforce in a tweet said it "could probably be whitelisted pretty easily". The concrete motivation is to support pages that use URL rewriting like below…

RewriteRule ^(\d{4})\/(\d{2})\/(\d{2})\/(.*?)$ /index.php?date=$1-$2-$3

…which rewrites http://example.org/2016/02/25/foobar to http://example.org/index.php?date=2016-02-25 and requires the base URL be set to http://example.org/ for local links to work.

Externally Tracked caching

Most helpful comment

Any progress on allowing actual URLs in the href attribute?

All 9 comments

Filed b/27356051 internally, because this first has to be support in AMP cache serving because it can be made valid.

Closing this old issue. <base href=/> is now valid. We may extend this in the future to other href values, but this works for the given use case.

While my first AMP pages have just gone live (e.g., https://cdn.ampproject.org/c/s/blog.tomayac.com/categories/technical), it seems like <base href=/> is not back-translated to the origin URL, as all links currently 404, e.g., https://cdn.ampproject.org/2015/06/24/mediterranea-js-trip-report-151125 that should actually point to https://blog.tomayac.com/2015/06/24/mediterranea-js-trip-report-151125 (a currently invalid AMP page, but irrelevant for the actual issue that <base href="/"> served from the AMP Cache forgets it should actually point to <base href="https://blog.tomayac.com/">, which is not allowed as a value).

(CC: @Gregable @cramforce)

That seems buggy, indeed. I would have expected the base tag to be removed from the output document and the links to be rewritten.

Reopened our internal issue.

This has been fixed on the cache. New documents or documents that change and are refreshed on the cache should have the correct tags. Still working on reprocessing existing documents.

@tomayac thanks for opening that. It's very common indeed. I have the same issue too, and I use the base tag for the same purpose as you mention.

However attn @Gregable @cramforce it seems this hasn't been fully fixed. Trying to validate my amp pages, I get the error [attribute 'href' in tag 'base' is set to the invalid value]. You can try a test version of it here. http://test1.shoppinginformer.com/amp-tst/stores/Lacoste/363

@sham77: We only allow /.

Any progress on allowing actual URLs in the href attribute?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aghassemi picture aghassemi  Â·  43Comments

zhouyx picture zhouyx  Â·  103Comments

retornam picture retornam  Â·  52Comments

darobin picture darobin  Â·  48Comments

choumx picture choumx  Â·  42Comments